好的,作为循环的一部分,我正在读取未知数量的文件名,并将它们保存到名称取决于文件夹中文件数量的变量中。像这样:
SET /a count=1
DIR %rootFolder%> "fileList.txt" /b
FOR /f "tokens=* delims= usebackq" %%a IN ("fileList.txt") DO CALL :LOOP %%a
goto :LOOP2
:Loop
SET var=%1
SET File%count%=%var%
SET /a count=%count%+1
GOTO:EOF
这很好用
ECHO File1
ECHO File2
输出
firstfile.txt
secondfile.txt
我遇到的问题是在稍后的循环中读出变量的内容,因为这段代码:
SET fileName=File%count%
ECHO %fileName%> temp.txt
输出
File1
当我希望它输出按该名称存储在变量中的值时。期望的输出:
firstfile.txt
有没有办法做到这一点?