Batch command date and time in file name

前端 未结 14 2314
闹比i
闹比i 2020-11-22 01:25

I am compressing files using WinZip on the command line. Since we archive on a daily basis, I am trying to add date and time to these files so that a new one is auto generat

14条回答
  •  日久生厌
    2020-11-22 01:41

    Extract the hour, look for a leading space, if found replace with a zero;

    set hr=%time:~0,2%
    if "%hr:~0,1%" equ " " set hr=0%hr:~1,1%
    echo Archive_%date:~-4,4%%date:~-10,2%%date:~-7,2%_%hr%%time:~3,2%%time:~6,2%.zip
    

提交回复
热议问题