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

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

    Use this batch script made by me:

    @echo off
    title Folder Creator
    color b
    setlocal enabledelayedexpansion
    echo Enter the folder name, you can use these codes:
    echo /t - Time (eg. 16:29)
    echo /d - Date (eg. 17-02-19)
    echo /a - Day (eg. 17)
    echo /m - Month (eg. 02)
    echo /y - Year (eg. 19)
    echo /f - Full Year (eg. 2019)
    echo.
    set /p foldername=Folder Name:
    set foldername=%foldername:/t=!time:~0,5!%
    set foldername=%foldername:/d=!date:~0,2!-!date:~3,2!-!date:~8,2!%
    set foldername=%foldername:/a=!date:~0,2!%
    set foldername=%foldername:/m=!date:~3,2!%
    set foldername=%foldername:/y=!date:~8,2!%
    set foldername=%foldername:/f=!date:~6,4!%
    md %foldername%
    

    For example if you wanted to make a folder named the date in the DD-MM-YY format you would type "/d" but if you wanted to do that in the DD-MM-YYYY format you would type "/a-/m-/f".

提交回复
热议问题