我正在尝试在 for 循环中使用索引并将其存储在变量中。我用这段代码写了一个批处理文件:
FOR /L %%x IN (1,1,3) DO (
ECHO %%x
SET tmp=prefix_%%x.suffix
ECHO tmp is %tmp%
)
运行它时,我得到:
1
tmp is prefix_3.suffix
2
tmp is prefix_3.suffix
3
tmp is prefix_3.suffix
我希望它是:
1
tmp is prefix_1.suffix
2
tmp is prefix_2.suffix
3
tmp is prefix_3.suffix
我究竟做错了什么?!