Reply
Old February 23rd, 2005 Top | #1
 
arew264's Avatar
OSNN Junior Addict
Joined: February 2005
Posts: 36
Reputation: 0
Power: 62

Default 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%2C4...386947%2C00.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.


arew264 is offline   Reply With Quote
Old February 23rd, 2005 Top | #2
 
arew264's Avatar
OSNN Junior Addict
Joined: February 2005
Posts: 36
Reputation: 0
Power: 62

Default Re: Batch File Problem

Originally Posted by arew264
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%2C4...386947%2C00.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.


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.
arew264 is offline   Reply With Quote
Old February 23rd, 2005 Top | #3
 
arew264's Avatar
OSNN Junior Addict
Joined: February 2005
Posts: 36
Reputation: 0
Power: 62

Default 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?
arew264 is offline   Reply With Quote
Old February 23rd, 2005 Top | #4
 
arew264's Avatar
OSNN Junior Addict
Joined: February 2005
Posts: 36
Reputation: 0
Power: 62

Default Batch FIle PLEASE HELP

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?
arew264 is offline   Reply With Quote
Old February 23rd, 2005 Top | #5
 
the_tazinator's Avatar
Are we there yet?
Joined: May 2002
Location: In a house
Posts: 177
Reputation: 40
Power: 97

Default Re: Batch FIle PLEASE HELP

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
the_tazinator is offline   Reply With Quote
Old February 23rd, 2005 Top | #6
 
arew264's Avatar
OSNN Junior Addict
Joined: February 2005
Posts: 36
Reputation: 0
Power: 62

Default Re: Batch FIle PLEASE HELP

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.
arew264 is offline   Reply With Quote
Old February 24th, 2005 Top | #7
 
chaos945's Avatar
OSNN Senior Addict
Joined: February 2003
Posts: 955
Reputation: 300
Power: 99

Default Re: Batch FIle PLEASE HELP

I threw togeather this little program. Run it from the cmdline.
Renames all specified file types to their creation date and time, then moves them to another folder.
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
File Type: zip timebch.zip (128.0 KB, 60 views)
chaos945 is offline   Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules

Similar Threads
Thread Thread Starter Forum Replies Last Post
vbscript or batch file to play audio file for user on startup Punkrulz Web Design & Coding 10 November 29th, 2006 1:48pm
BATCH file help dillinja Web Design & Coding 0 March 24th, 2006 9:43am
Batch File Q omg its nlm Web Design & Coding 4 March 10th, 2004 1:24am
Batch File Help the_tazinator Windows Desktop Systems 4 November 21st, 2003 12:12am
XP Batch file RogerPhillis Windows Desktop Systems 4 November 24th, 2002 11:18pm