Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 需要帮助获取批处理文件以读取输入,但奇怪的是,它在第一部分工作正常_Batch File - Fatal编程技术网

Batch file 需要帮助获取批处理文件以读取输入,但奇怪的是,它在第一部分工作正常

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"

这是我的代码,第一部分执行得很好,但第二部分不是,它只是将每个变量显示为空白。我不知道为什么它的格式相同,也可以将:readprofiles部分放在working for变量中

该程序的目的:列出一个目录作为配置文件以及编号的选择。基本上是菜单

@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