按限制顺序创建多个文件

时间:2014-12-19 17:36:25

标签: batch-file

您正在处理批处理文件,该文件将按顺序编号文件或键入新文件名。如果要按顺序命名文件,则会询问用户输入的起始编号和结束编号。我无法弄清楚如何从用户输入的起始编号开始创建新文件,并且只添加文件到最终编号。到目前为止我的代码看起来像这样:

@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 个答案:

答案 0 :(得分: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