Batch FIle PLEASE HELP

Discussion in 'Windows Desktop Systems' started by arew264, Feb 23, 2005.

  1. arew264

    arew264 OSNN Junior Addict

    Messages:
    36
    Batch File Problem

    I have Norton GHost to do backups between three computers, and I need help making a batch file that renames the backup files that Ghost creates to the time and date they were created. I could replace this with a batch that simply names them to today's date as I will be running this file as a scheduled task the day the backup is created. The batch file I'm looking for should:

    rename the files to match the date they were made
    copy them to \\wielinator\backups\XP
    move them to C:\backups\XP\old

    The files I want this done to are in C:\backups\XP\New
    THis is all part of a large scheduling, organizing, and copying plan that keeps three computers backed up and lets them do the backups when I don't have to worry about someone getting ticked off because their stuff got lost when they were working on it. I have the copy command with all the echo labeling I need:

    ECHO OFF
    ECHO This batch file copies the C drive backup files to the WIelinator
    ECHO READY TO BACKUP
    ECHO backing up...
    COPY "C:\BACKUPS\XP\NEW" "\\WIELINATOR\BACKUPS\XP"
    ECHO All done! I think I can do the move part of the file, but I can't get the renaming to work. I also tried the suggestion at http://www.pcmag.com/article2/0,4...386947,00.asp but it would not work. I'm sure theres someone here who really knows how to make a batch file that can help me.


     
  2. arew264

    arew264 OSNN Junior Addict

    Messages:
    36
    Re: Batch File Problem

    I came up with this code but could not get it to work:

    @ECHO OFF
    FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%J-%%K-%%L
    ECHO The value is "%mydate%"
    ren C:\backups\XP\New\C_drive001.v2i %mydate%.v2i
    copy C:\backups\XP\New\%mydate%_Cdrive.v2i \\wielinator\backups\XP\Old\%mydate%_Cdrive.v2i
    move C:\backups\XP\New\%mydate%_Cdrive.v2i C:\backups\xp\old\%mydate%_Cdrive.v2i

    could someone please help me? I can't get the rename to work.
     
  3. arew264

    arew264 OSNN Junior Addict

    Messages:
    36
    Re: Batch File Problem

    I just found this code:

    For /F "tokens=2-4 delims=. " %%A in ('Date /T') Do Rename C:\backups\XP\new\C_driveoo1.v2i %%A%%B%%C_drive001.v2i

    it works fine but could someone help me get it to separate the date with hyphens instead of slashes?
     
  4. arew264

    arew264 OSNN Junior Addict

    Messages:
    36
    I'm using this line of code to rename a backup file and I have already created a script that moves it to a different folder. THe backup program will make the file and I will run this batch file to rename it to the date and move it.

    For /F "tokens=2-4 delims=. " %%A in ('Date /T') Do Rename C:\backups\XP\new\C_driveoo1.v2i %%A%%B%%C_drive001.v2i

    I need to get this code to separate the date with hyphens instead of slashes. can someone please help me?
     
  5. the_tazinator

    the_tazinator Are we there yet?

    Messages:
    177
    Location:
    In a house
    Try this and see if it work the way you want.

    for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do ren "C:\backups\XP\new\C_driveoo1.v2i" %%a-%%b-%%c-C_drive001.v2i
     
  6. arew264

    arew264 OSNN Junior Addict

    Messages:
    36
    Thanks for your help. THere is one more thing though. I have a third computer running windows 98 what I'm sending the backups to. I have a batch file on there that I needed this code for also but it wouldn't work. Here's the code:

    copy C:\backups\xp\new\ \\ex98\backups\xp\new\
    copy C:\backups\98\new\ \\XP\backups\98\new\
    for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do move C:\backups\98\new\%%b-%%a-%%c-98C_drive.v2i C:\backups\98\old\%%b-%%a-%%c-98C_drive.v2i
    for /f "tokens=2,3,4 delims=/ " %%a in ('date /t') do move C:\backups\XP\new\%%b-%%a-%%c-XPC_drive.v2i C:\backups\XP\old\%%b-%%a-%%c-XPC_drive.v2i

    I hope someone can find a way to make this work on windows 98 like it did on XP.
     
  7. chaos945

    chaos945 Moderator

    Messages:
    934
    I threw togeather this little program. Run it from the cmdline.
    I don't know if it will work on win9x systems though, let me know and I can revise it.

    Example:
    timebch.exe <source> <destination> <filetype>
    timebch.exe "C:\ghost\files\\" "C:\ghost\backup\" "bak"

    Visit the AutoIt forums if you want to follow the progress of this script
     

    Attached Files: