How to append a date in batch files

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

    You can also access the date via the variable %DATE%

    When testing my system %DATE% produces ffffd dd/mm/yyyy

    you can use substring operators to produce the format you desire

    ie. running the following on MON 11/12/2018 with US regional settings

    %DATE:~3,3% %DATE:~0,3% %DATE:~7,2%
    

    Will produce an output:

    11 Mon 12
    

    the substring arguments are
    %*variable*:~*startpos*,*numberofchars*%

提交回复
热议问题