English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Backing up a data file weekly to a portable hard drive. I do not want to overwrite the file each week. So I'm trying to modify the filename to include the current date as part of the filename. The batch file to do the backup is fine, just need a way to modify the name of the created file.

2006-11-11 03:05:46 · 3 answers · asked by Karl 1 in Computers & Internet Programming & Design

3 answers

REM == Lets get your current filename
SET MYFILE=yserver.txt


Rem === put the current date in a variable
SET MYDATE=%DATE%

Rem file names can't contain things like / so lets replace them with _
SET MYDATE=%MYDATE:/=_%
SET MYDATE=%MYDATE: =_%
echo %MYDATE%

REM == Now rename add the date the beginning of myfile
ren "%MYFILE%" "%MYDATE%%MYFILE%"

2006-11-11 03:15:02 · answer #1 · answered by Javelinl 3 · 0 0

I think you need to get a backup program that has the many options you need.

As long as the batch file contains the name of the file, you will continuously overwrite it. To stop that, you need to modify the batch file and rename the file to be saved just prior to running the batch file.

An alternative is to identify your backup destinations and name them Sunday thru Saturday. then use the appropriate day of the week medium so you always have the last 7 days backup of the file.

2006-11-11 03:16:48 · answer #2 · answered by snvffy 7 · 0 0

typing in the following will rename a file.

rename your.txt yournewname.txt

This will rename a file in XP-DOS

2006-11-11 03:14:49 · answer #3 · answered by loodem 1 · 0 0

fedest.com, questions and answers