Batch file 将文本文件中的特定行读取到集合;lineinfo=第1行或第2行的文本“;在批处理文件中

Batch file 将文本文件中的特定行读取到集合;lineinfo=第1行或第2行的文本“;在批处理文件中,batch-file,text,Batch File,Text,我试图让批处理文件从文本文件中读取特定行,并设置NewHDLocation=“then here is the text from the line in the txt”,然后执行2次,以便稍后我可以执行%NewHDLocation%和%WOTinstalldir%来告诉命令该信息 我的代码示例: for /F "skip=0 delims=" %%i in (Settings.txt) do if not defined NewHDLocation set "NewHDLocation=%%

我试图让批处理文件从文本文件中读取特定行,并设置NewHDLocation=“then here is the text from the line in the txt”,然后执行2次,以便稍后我可以执行%NewHDLocation%和%WOTinstalldir%来告诉命令该信息

我的代码示例:

for /F "skip=0 delims=" %%i in (Settings.txt) do if not defined NewHDLocation set "NewHDLocation=%%i"&goto next

:next
for /F "skip=1 delims=" %%i in (Settings.txt) do if not defined WOTinstalldir set "WOTinstalldir=%%i"&goto next2

:next2
@echo %NewHDLocation%
@echo %WOTinstalldir%
pause
最后2@echo只是测试它是否从txt中获取信息,但它只是输出:

C:\WINDOWS\system32>for /F "skip=0 delims=" %i in (Settings.txt) do if not defined NewHDLocation set "NewHDLocation=%i"  & goto next
 delims=" was unexpected at this time.

C:\WINDOWS\system32>for /F "skip=1 delims=" %i in (Settings.txt) do if not defined WOTinstalldir set "WOTinstalldir=%i"  & goto next2

C:\WINDOWS\system32>if not defined WOTinstalldir set "WOTinstalldir=ECHO is on."  & goto next2
ECHO is on.
ECHO is on.

C:\WINDOWS\system32>pause
Press any key to continue . . .
在我需要读取的文本文件中,我写道(仅用于测试):


在这个特定的实例中,我可能只是将文件流式传输到一个代码块中

@ECHO OFF
<settings.txt (
set /p "NewHDLocation="
set /p "WOTinstalldir="
)

echo %NewHDLocation%
echo %WOTinstalldir%
pause
@ECHO关闭

在这个特定的实例中,我可能只是将文件流式传输到一个代码块中

@ECHO OFF
<settings.txt (
set /p "NewHDLocation="
set /p "WOTinstalldir="
)

echo %NewHDLocation%
echo %WOTinstalldir%
pause
@ECHO关闭