如何在批处理中读取和解析带有特殊字符的文件?我有一个名为 test.txt 的文本文件foo!!!bar
和一个批处理文件:
@echo off
setlocal enabledelayedexpansion enableextensions
FOR /F "tokens=* delims=" %%a IN (.\test.txt) DO (
echo Unquoted is %%a
echo Quoted is "%%a"
set "myVar=%%a"
echo myVar is still !myVar! or "!myVar!"
)
exit /b 0
我希望并期望它以foo!!!bar
某种方式输出,但这会输出:
Unquoted is foobar
Quoted is "foobar"
myVar is still foobar or "foobar"
我当然可以type test.txt
,但我想处理文件的每一行。