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