Batch file 需要帮助获取批处理文件以读取输入,但奇怪的是,它在第一部分工作正常
这是我的代码,第一部分执行得很好,但第二部分不是,它只是将每个变量显示为空白。我不知道为什么它的格式相同,也可以将:readprofiles部分放在working for变量中 该程序的目的:列出一个目录作为配置文件以及编号的选择。基本上是菜单Batch file 需要帮助获取批处理文件以读取输入,但奇怪的是,它在第一部分工作正常,batch-file,Batch File,这是我的代码,第一部分执行得很好,但第二部分不是,它只是将每个变量显示为空白。我不知道为什么它的格式相同,也可以将:readprofiles部分放在working for变量中 该程序的目的:列出一个目录作为配置文件以及编号的选择。基本上是菜单 @echo off setlocal enabledelayedexpansion set Counter=1 for /f "DELIMS=" %%i in (test.txt) do ( set "Line_!Counter!=%%i"
@echo off
setlocal enabledelayedexpansion
set Counter=1
for /f "DELIMS=" %%i in (test.txt) do (
set "Line_!Counter!=%%i"
set /a Counter+=1
)
set /a NumLines=Counter - 1
:: this part is a test
echo %Line_1%
echo %Line_2%
echo %Line_3%
echo %Line_4%
echo %Line_5%
echo %Line_6%
:: end test
set Counter=1
:readprofiles
if %Counter%==%NumLines% goto pause
echo %Counter%. %Line_!Counter!%
set /a Counter+=1
goto readprofiles
:pause
pause
echo%计数器%!行%Counter%代码>
@echo off
setlocal enabledelayedexpansion
set Counter=0
for /f "DELIMS=" %%i in (test.txt) do (
set /a Counter+=1
set "Line_!Counter!=%%i"
)
For /L %%C in (1,1,%Counter%) Do echo %%C. !Line_%%C!
Pause