Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Name: William Lockie (by blockie)
I am anxious to learn how to date stamp backup files. Presently the backup program I am using backs up to a file using the same name, thereby overwriting yesterdays file . I wind up with only the last backup made.
I would like to append the date, in mm/dd/yy format, to the file name created. This way each backup would have a unique name and I could have more than one backup.
I am, otherwise, satisfied with this backup program so please do not recommend another program as your answer. Just show me how to do this.
Thanks,
BillExisting filename........TEST.TXT
New filename.............TEST_05/22/08.TXTWilliam Lockie
"OS: WXP SP2
CPU/Ram: 3.0/2GB
Manufacturer/Model: clone"

Instead of renaming the file, can you have the backup program save all the days backups to a new 'dated' folder for each day?
You are very wise to have multiple backups.

Is the program name a secret? Might it help us to know it's name?
I would suggest ntbackup but I don't know if you are using that.
"Best Practices", Event viewer, host file, perfmon, are in my top 10

The program name is not a secret. It is DriveImage XML from Runtime Software.
I have customized it so that I can run it from a batch file and then I put it in the Windows scheduler.
Here's the script in the batch file;"C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bc /tD:\Images\Drive_C /r- /s- /c /v
Hope this helps.
Bill
PS: Drive_c in the above script is the filename generated during backup.William Lockie
"OS: WXP SP2
CPU/Ram: 3.0/2GB
Manufacturer/Model: clone"

Ok Razor2.3.
Lets do it with Test_052208,text. I really don't care as long as I can see the difference from day to day and not overwrite the old file.
BillWilliam Lockie
"OS: WXP SP2
CPU/Ram: 3.0/2GB
Manufacturer/Model: clone"

You'll need a multiline batch file. This should do the trick. I found the code for everything but the last line from someone named seamonkey420.
The last line will change to a directory called d:\imagesMMDDYYYY (for example d:\images05282008).
If your backup software doesn't create directories automatically you'll need to add the line "mkdir d:\images%date%" before the command that actually runs the backup software.
echo on
@REM Seamonkey's quick date batch (MMDDYYYY format)
@REM Setups %date variable
@REM First parses month, day, and year into mm , dd, yyyy formats and then combines to be MMDDYYYYFOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date=%mm%%dd%%yyyy%echo D:\Images%date%\Drive_C

Oops, sorry, the last line should be:
C:\Program Files\Runtime Software\DriveImage XML\dixml.exe" /bc /tD:\Images%date%\Drive_C /r- /s- /c /v
I was using the echo command to test the batch file

To avoid the can of worms involved with date layouts...
This will sequentially number them.
::== seqNtest.bat
:: seq num backups@echo off
setLocal EnableDelayedExpansionif not exist test.txt echo nothing to do && goto :eof
for /f "tokens=* delims= " %%a in ('dir/b/a-d/od test_*.txt') do (
set str=%%~Na
set /a N=!str:~5!
)set /a N+=1
ren test.txt test_!N!.txt
::== doneHi Razor2.3,
yep no slashes, no stars and bars, no redirects etc
=====================================
If at first you don't succeed, you're about average.M2

FOR Mechanix2Go
Here it is the modified, for me, the batch file you provided. It does NOT work. At least it does not work after I modified it.
It did work in its original form when I created a test.txt in the same folder as the batch file.
My backup files are on another drive as you can see by the changes I made,
I do not know what the parameters mean after
"dir/b/". This may be the problem. I will continue to work on it,but I hope you are able to detect the error and show me the TRUE way.
Bill@echo off
setLocal EnableDelayedExpansion
if not exist D:\DriveImage\drive_c.dat echo nothing to do && goto :eof
for /f "tokens=* delims= " %%a in ('dir/b/a-d/od D:\DriveImage\drive_*.dat') do (
set str=%%~Na
set /a N=!str:~5!
)
set /a N+=1
ren D:\DriveImage\drive_c.dat D:\DriveImage\drive-c_!N!.dat
ren D:\DriveImage\drive_c.xml D:\DriveImage\drive_c_!N!.xmlWilliam Lockie
"OS: WXP SP2
CPU/Ram: 3.0/2GB
Manufacturer/Model: clone"

It's not obvious what's going wrong. You can eliminate some clutter and make the troubleshooting easier by changing to the directory where the files are.
::==
@echo off
setLocal EnableDelayedExpansionpushd D:\DriveImage
if not exist... blah blah
=====================================
If at first you don't succeed, you're about average.M2

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |