6
tests.txt中每個文本的最後一個單詞是「</a>」,我輸入了這個單詞並且它似乎沒有問題,但當我echo
在for
循環中,cmd給了我這個錯誤:「系統找不到指定的文件。」
我知道問題出在「<」和「>」符號上,它代表重定向,這就是錯誤的產生方式。我如何讓cmd認爲我正在使用字符串而不是重定向?BATCH - 使用字符串(< , >)而不是重定向
@echo off
setlocal EnableDelayedExpansion
set "remove_char=< /a>"
echo !remove_char!
for /f "skip=2 tokens=6*" %%a in (testing.txt) do (
set "string=%%a %%b"
set string=!string:%remove_char%=!
echo !string!
)
pause >nul
[如何將重定向符號(< and >)傳遞給Windows批處理文件函數?](http://stackoverflow.com/questions/21406151/how-to-pass-redirect-symbols-and-to- a-windows-batch-file-function) –
嘗試使用'set「string =!string:%remove_char%=!」' – npocmaka