• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Batch FIle PLEASE HELP

arew264

OSNN Junior Addict
#1
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.


 

arew264

OSNN Junior Addict
#2
Re: Batch File Problem

arew264 said:
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.


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

OSNN Junior Addict
#3
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

OSNN Junior Addict
#4
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?
 

the_tazinator

Are we there yet?
#5
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
 

arew264

OSNN Junior Addict
#6
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
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
 

Attachments

Members online

No members online now.

Latest posts

Latest profile posts

Perris Calderon wrote on Electronic Punk's profile.
Ep, glad to see you come back and tidy up...did want to ask a one day favor, I want to enhance my resume , was hoping you could make me administrator for a day, if so, take me right off since I won't be here to do anything, and don't know the slightest about the board, but it would be nice putting "served administrator osnn", if can do, THANKS

Been running around Quora lately, luv it there https://tinyurl.com/ycpxl
Electronic Punk wrote on Perris Calderon's profile.
All good still mate?
Hello, is there anybody in there? Just nod if you can hear me ...
Xie
What a long strange trip it's been. =)

Forum statistics

Threads
61,962
Messages
673,241
Members
89,016
Latest member
timpage