Batch command date and time in file name

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

    I prever to use this over the current accepted answer from Stephan as it makes it possible to configure the timestamp using named parameters after that:

    for /f %%x in ('wmic path win32_utctime get /format:list ^| findstr "="') do set %%x

    It will provide the following parameters:

    • Day
    • DayOfWeek
    • Hour
    • Milliseconds
    • Minute
    • Month
    • Quarter
    • Second
    • WeekInMonth
    • Year

    You can then configure your format like so:

    SET DATE=%Year%%Month%%Day%

提交回复
热议问题