I have a for loop that processes dropped file(s), but I have recently come across a file whose filename includes &
and I get an error of & was unexpected at this time
. So I am not sure why it's doing it, I have it enclosed in quotes.
Filename example: [This_&_That]_FileName.txt
Small example:
FOR /F "tokens=* delims=;" %%P in ("%*") do call :LOOP %%P
:LOOP
if '%1'=='' goto :endloop
echo %1
pause
....
:endloop
exit
This works fine with spaces, but with the &
symbol it crashes. I have to run the .bat file from cmd
with the file name as an argument just to see the error.
I have tried enabling delayedexpansion - like in this post and either I didn't do it correctly or it just doesn't work for me: stackoverflow post