Batch command date and time in file name

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

    @For /F "tokens=1,2,3,4 delims=/ " %%A in ('Date /t') do @(
    
    Set DayW=%%A
    
    Set Day=%%B
    
    Set Month=%%C
    
    
    Set Year=%%D
    
    
    Set All=%%D%%B%%C
    )
    "C:\Windows\CWBZIP.EXE" "c:\transfer\ziptest%All%.zip" "C:\transfer\MB5L.txt"
    

    This takes MB5L.txt and compresses it to ziptest20120204.zip if run on 4 Feb 2012

提交回复
热议问题