我编写了一个创建文件夹的批处理脚本。路径作为输入参数给出,文件夹名称是今天的日期。
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set year=%%c
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set month=%%a
for /f "tokens=2-4 delims=/ " %%a in ('date /T') do set day=%%b
set TODAY=%day%_%month%_%year%
mkdir %1% %TODAY%
我得到的输出如下:
arvind_test.bat C:\Users\M1015807\Desktop\logs\ C:\Users\M1015807\Desktop\logs\
C:\Users\M1015807\Desktop\zip\test>for /F "tokens=2-4 delims=/ " %a in ('date /T') do set year=%c
C:\Users\M1015807\Desktop\zip\test>set year=2013
C:\Users\M1015807\Desktop\zip\test>for /F "tokens=2-4 delims=/ " %a in ('date /T') do set month=%a
C:\Users\M1015807\Desktop\zip\test>set month=04
C:\Users\M1015807\Desktop\zip\test>for /F "tokens=2-4 delims=/ " %a in ('date /T') do set day=%b
C:\Users\M1015807\Desktop\zip\test>set day=16
C:\Users\M1015807\Desktop\zip\test>set TODAY=16_04_2013
C:\Users\M1015807\Desktop\zip\test>mkdir C:\Users\M1015807\Desktop\logs\TODAY
A subdirectory or file C:\Users\M1015807\Desktop\logs\TODAY already exists.
>> was unexpected at this time.
任何人都可以帮助请..