【发布时间】:2016-04-29 15:43:28
【问题描述】:
我试图运行的命令是:
::%items% is defined elsewhere and is the amount of items per line in the file
FOR /F "usebackq tokens=1-%items% delims=," %%1 IN (`TYPE %TextFile%`) DO (
FOR /l %%a in (%items%,-1,1) do (
set /a "number=%%a"
echo !number!
:: This is the main command I believe im having issues with
set word!number!=%%!number!
echo !word1!
echo !word2!
echo !word3!
)
set /a "lineused%randomline%=1"
goto exitloop
)
:exitloop
pause
现在我要做的是设置名为 wordX 的变量,其中 X 是令牌的编号。编辑:基本上,尝试使用下部 for 循环中运行的 %% 变量。 我可以输入所有的行
set word1=%%1
set word2=%%2
set word3=%%3
但这会破坏我正在尝试构建的多功能系统的目的。 在这种情况下,文本文件 (%TextFile%) 的格式就是:
line1i1,line1i2
line2i1,line2i2
但我需要它也可以工作,例如:
line1i1,line1i2,line1i3,line1i4
line2i1,line2i2,line2i3,line1i4
【问题讨论】:
标签: batch-file for-loop