I want to run a daily incremental backup and append the day of the week to the file name so I end up with:

backup_mon.bak
backup_tue.bak

etc.

Not really bothered about what exactly is appended - 0 - 6 is fine.

How do I go about this?

link|improve this question
feedback

2 Answers

Take a look at Advanced date and time math in batch files. You find there a subroutine which converts a date to the Julian calendar and another one which will tell you the weekday.

link|improve this answer
feedback

If you have no problem calling an external script, you can use VBScript to get the day of week very easily:

the VBScript code:

wscript.echo WeekdayName(Weekday(Date))

Calling it and using it in your filename:

for /f "delims=" %%a in ('cscript /nologo dayofweek.vbs') do @set myvar=%%a
set filename=backup_%myvar%.bak

then later in your script you can use the variable %filename% to access it. If I ran this today for example, it would create a file called backup_Sunday.bak. Ensure the VBscript file is in the same directory as the batch script.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.