Batch command date and time in file name

前端 未结 14 2300
闹比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:50

    I found the best solution for me, after reading all your answers:

    set t=%date%_%time%
    set d=%t:~10,4%%t:~7,2%%t:~4,2%_%t:~15,2%%t:~18,2%%t:~21,2%
    echo hello>"Archive_%d%"
    

    If AM I get 20160915_ 150101 (with a leading space and time).

    If PM I get 20160915_2150101.

提交回复
热议问题