Home » Questions » Computers [ Ask a new question ]

Adding Day Of week to file name in batch file

Adding Day Of week to file name in batch file

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

Asked by: Guest | Views: 226
Total answers/comments: 1
Guest [Entry]

"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."