How do I read and parse a file with special characters in Batch? I have a text file named test.txt with just foo!!!bar
and a batch file with this:
@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
I want and expect it to output foo!!!bar
somehow, but this outputs:
Unquoted is foobar
Quoted is "foobar"
myVar is still foobar or "foobar"
Of course I can just type test.txt
, but I want to process each line of the file.