New
#1
batch file help: parentheses
I have the following batch commands to extract and compare the last character of strings in a file:
@for /f "tokens=1 delims=;" %%A in ( C:\test.txt) do set d=%%A
@echo %d%
@echo %d:~-1%
@set c=%d:~-1%
@echo %c%
@if %c%==m @echo found it
It works as I hoped but only for the last line in the file test.txt. I'd like to have the batch commands work on every line in the file test.txt. So, I put commands after the "do' command in parentheses. Now, nothing works. I got an error message saying "@echo was unexpected at this time."
My guess is one of the variable is now empty. So, I add before the "For" command "setlocal EnableDelayedExpansion." It did not help and I don't know what triggers the error message.