How to append a date in batch files

后端 未结 14 2141
夕颜
夕颜 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:11

    If you have WSL enabled (Windows 10 only) you can do it with bash in a locale neutral way.

    set dateFile=%TEMP%\currentDate.txt
    bash -c "date +%Y%m%d" > %dateFile%
    set /p today=<%dateFile%
    

    Feel free to replace the file redirection with a "for" loop abomination suggested in other answers here and over at Windows batch assign output of a program to a variable

提交回复
热议问题