How to create a folder with name as current date in batch (.bat) files

前端 未结 24 1258
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 02:26

I don\'t know much about windows .bat file syntax. My simple requirement is to create a folder at a specific location with name as current date. I tried searching this on go

24条回答
  •  隐瞒了意图╮
    2020-12-08 02:33

    I use the next code to make a file copy (e.g. test.txt) before replacing:

    cd /d %~dp0
    set backupDir=%date:~7,2%-%date:~-10,2%-%date:~-2,2%_%time:~0,2%.%time:~3,2%.%time:~6,2%
    echo make dir %backupDir% ...
    md "%backupDir%"
    copy test.txt %backupDir%
    

    It creates directory in format DD-MM-YY_HH.MM.SS and places text.txt there. Time with seconds in the name is necessary to create directory without additional verification.

提交回复
热议问题