Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is wrong with my for /f statement

Can someone please explain what is wrong with my for statement? I'm trying to run it as a bat file. I've looked at various examples online and I can't seem to figure out why I get a syntax error

FOR /F "tokens=*" %%A in (c:\scripts\destination.txt) DO 
(
echo inside the for loop
pause
)

I get the following error:

The syntax of the command is incorrect. C:\Scripts>FOR /F "tokens=*" %A in (c:\scripts\destination.txt) DO

like image 388
rka257 Avatar asked Nov 23 '25 05:11

rka257


1 Answers

The parenthesis has to be on the same line.

tokens=* removes leading whitespace - the delims= doesn't.

FOR /F "delims=" %%A in (c:\scripts\destination.txt) DO (
echo %%A - inside the for loop
pause
)
like image 125
foxidrive Avatar answered Nov 28 '25 17:11

foxidrive