Windows Shell 脚本:无法在子例程中进行字符串替换
尊敬的专家们您好!
您能否建议我如何解决这个问题:
@echo off
cls
setlocal enabledelayedexpansion
path=%CD%;%path%
set NumberOfPages=553
rem set /A MaxFileIndex=%Counter% - 1
set MaxFileIndex=1
del Output.txt
for /l %%i in (0,1,%MaxFileIndex%) do call :GenerateFileList %%i
goto :eof
::::::::::::::::::::::::::
:GenerateFileList
::::::::::::::::::::::::::
setlocal enabledelayedexpansion
set CurrentFileName="File(%1).txt"
echo !CurrentFileName:"=! > Output.txt
goto :eof
::::::::::::::::::::::::::
:eof
::::::::::::::::::::::::::
endlocal
此代码在屏幕上回显,而不是写入“ExtractedLinks.txt”。这里有什么问题呢?
Greetings dear Experts!
Could you please advice me on how to cope with the problem:
@echo off
cls
setlocal enabledelayedexpansion
path=%CD%;%path%
set NumberOfPages=553
rem set /A MaxFileIndex=%Counter% - 1
set MaxFileIndex=1
del Output.txt
for /l %%i in (0,1,%MaxFileIndex%) do call :GenerateFileList %%i
goto :eof
::::::::::::::::::::::::::
:GenerateFileList
::::::::::::::::::::::::::
setlocal enabledelayedexpansion
set CurrentFileName="File(%1).txt"
echo !CurrentFileName:"=! > Output.txt
goto :eof
::::::::::::::::::::::::::
:eof
::::::::::::::::::::::::::
endlocal
This code echoes on the screen instead of writing to "ExtractedLinks.txt". What is the problem here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您的意思是 Output.txt 而不是 ExtractedLinks.txt:
另外,除非您在 for 循环中执行其他操作,否则您可能想要附加而不是覆盖:
如果您确实希望文件名成为 ExtractedLinks.txt,只需更改它即可。
I assume you mean Output.txt not ExtractedLinks.txt:
Also, unless you are doing something else in the for loop, you probably want to append instead of overwriting:
And if you really want the filename to be ExtractedLinks.txt just change it.