我已經寫了一個批處理腳本來創建一個文件夾。路徑作爲輸入參數給出,文件夾名稱是今天的日期。批處理腳本變量是這樣打印的
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.
任何一個可以幫助請..
嗨,謝謝paxdiablo我一直都是新來編寫批處理腳本。它工作正常。並感謝您的解釋 – Arvind