CODE: [Copy to clipboard]
@echo off
for /f "delims=: tokens=1,2*" %%i in ('"findstr /n . list.txt"') do set %%i=%%j && set num=%%i
setlocal ENABLEDELAYEDEXPANSION
for /l %%l in (1,1,%num%) do call :dosomething "!%%l!"
echo 开始创建目录...
for %%m in (%strAll%) do md %%m\backup
pause
goto :eof
:dosomething
set /p str=输入 %1 的目录:
if "%str%" == "" goto error
dir %str% >nul 2>nul || goto :error
set strAll=%strAll% "%str%"
goto :eof
:error
echo 目录不存在!
echo 按任意键退出...
pause>nul
exit
goto :eof
在最后,还是想说的是:用批处理来处理文本内容的时候还是很麻烦的,上面的脚本并没有做更多的出错检测及处理。当文本文件的内容中包含有&,|,&&,||等特殊字符时,还是很可能引起错误的,如果你的要求比较高可以自己尝试加入一些判断并处理错误的语句。