I\'m trying to process a list of file names but don\'t know how to \"escape\" the command line to produce consistent output regardless of whether the name contains plain tex
I think this will work as well.
@echo off
set /a COUNT=0
for /f "tokens=*" %%g in ('dir /b *.txt') do (
set /a COUNT+=1
set "file=%%g"
call :LIST file COUNT
)
pause
exit
:LIST
setlocal enabledelayedexpansion
echo !%2! !%1!
endlocal
goto :EOF
Output
1 01 A Test.txt
2 02 & Test.txt
3 03 ! test.txt
4 04 % test.txt
Press any key to continue . . .