且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用bat文件夹创建

更新时间:2023-09-25 22:15:52

您可以使用一个子和内置%DATE%和%TIME%变量来做到这一点:

You can use a substring and the built-in %DATE% and %TIME% variables to do this:

@echo OFF

:: Use date /t and time /t from the command line to get the format of your date and
:: time; change the substring below as needed.

:: This will create a timestamp like yyyy-mm-dd-hh-mm-ss.
set TIMESTAMP=%DATE:~10,4%-%DATE:~4,2%-%DATE:~7,2%-%TIME:~0,2%-%TIME:~3,2%-%TIME:~6,2%

@echo TIMESTAMP=%TIMESTAMP%

:: Create a new directory
md "%1\%TIMESTAMP%"