[英]Windows Shell Script: Can't make string substitution working in subroutine
親愛的專家,您好!
您能否建議我如何解決該問題:
@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”。 這里有什么問題?
我假設您的意思是Output.txt而不是ExtractedLinks.txt:
set c=!CurrentFileName:"=!
echo %c% > Output.txt
另外,除非您在for循環中做了其他事情,否則您可能希望追加而不是覆蓋:
echo %c% >> Output.txt
而且,如果您確實希望將文件名提取為ExtractedLinks.txt,則只需對其進行更改。
echo %c% >> ExtractedLinks.txt
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.