Batchfile to create backup and rename with timestamp

后端 未结 5 857
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-31 20:35

I have the following network path to copy the file to an archive folder. It copies File 1 from Folder to Archive but I would like to add t

5条回答
  •  攒了一身酷
    2021-01-31 21:10

    See if this is what you want to do:

    @echo off
    for /f "delims=" %%a in ('wmic OS Get localdatetime  ^| find "."') do set dt=%%a
    set YYYY=%dt:~0,4%
    set MM=%dt:~4,2%
    set DD=%dt:~6,2%
    set HH=%dt:~8,2%
    set Min=%dt:~10,2%
    set Sec=%dt:~12,2%
    
    set stamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%
    
    copy "F:\Folder\File 1.xlsx" "F:\Folder\Archive\File 1 - %stamp%.xlsx"
    

提交回复
热议问题