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

前端 未结 24 1294
被撕碎了的回忆
被撕碎了的回忆 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:46

    Thanks for the info all, very helpful. I needed something that could create "backup" folder as often as every minute in the same directory, as well as call on it later in the script. Here's what I came up with:

    @ echo off
    
    CD %userprofile%\desktop
    
    SET Datefolder="%DATE:~4,2%-%DATE:~7,2%-%DATE:~12,2%_%time:~1,1%%time:~3,2%"
    
    MD "%Datefolder%"
    

    This gives me a folder on the currently logged on user's desktop named: mm-dd-yy_hmm (hour minute minute) ie: 07-28-15_719

提交回复
热议问题