2014-12-19 70 views
0

您好我正在處理一個批處理文件,它將按順序編號文件或鍵入新的文件名。如果要按順序命名文件,則會向用戶詢問起始號碼和結束號碼。我無法弄清楚如何從用戶輸入的開始號碼開始創建新文件,只添加文件直到結束號碼。到目前爲止我的代碼看起來是這樣的:依次創建多個文件限制

@echo off 
setlocal 
:getConfirmation 
set /p consecutive="Are folders numbered consecutively?(y/n): " [y/n] ?: 
if %consecutive%==y goto :consecutivefiles 
if %consecutive%==n goto :nonconsecutivefiles 

:consecutivefiles 

set /p start="Starting file number: " 
set /p end="Ending file number: " 
md 
EXIT 

:nonconsecutivefiles 

set /p name="Type folder name(s): " 
md %name%, 

回答

1

您可以設置一個for /L環通號碼進行迭代。

@echo off 
set /p start_num="Starting file number:" 
set /p end_num="Ending file number:" 

for /L %%A in (%start_num%,1,%end_num%) do md folder_%%A 
exit /b