How to append a date in batch files

后端 未结 14 2181
夕颜
夕颜 2020-12-01 03:25

I have the following line in a batch file (that runs on an old Windows 2000 box):

7z a QuickBackup.zip *.backup

How do I append the date to

14条回答
  •  情话喂你
    2020-12-01 04:14

    Bernhard's answer needed some tweaking work for me because the %DATE% environment variable is in a different format (as commented elsewhere). Also, there was a tilde (~) missing.

    Instead of:

    set backupFilename=%DATE:~6,4%%DATE:~3,2%%DATE:0,2%

    I had to use:

    set backupFilename=%DATE:~10,4%%DATE:~4,2%%DATE:~7,2%

    for the date format:

    c:\Scripts>echo %DATE%

    Thu 05/14/2009

提交回复
热议问题