staples
staples

Reputation: 424

Batch file for loop has a syntax error

I have a batch for loop with a The syntax of the command is incorrect error. I am reading a file

setlocal EnableDelayedExpansion
set /a filecnt=1
set /a emptylist=1
for /f "delims=  " %%x in ('type "%execution_list_file%"') do ( 
  set /a emptylist=0
  echo File number !filecnt! >> %logfile% 2>&1
  set /a sleepcnt=0
  set /a found=0

::call :lookup

  set /a filecnt=!filecnt!+1
)

My file has a bunch of file paths in it likes this:

\\VDI\Prod\Dataloads\PROD\FileName01.csv
\\VDI\Prod\Dataloads\PROD\FileName02.csv

What is wrong with my syntax?

Upvotes: 0

Views: 494

Answers (1)

SomethingDark
SomethingDark

Reputation: 14325

While it is used for commenting code, :: is technically a label.

Code blocks do not behave correctly when they have labels in them, because of how batch parses code.

When you are inside of for loops, multiline if statements, and other lines of code wrapped in parentheses, you should use rem to comment instead.

Upvotes: 2

Related Questions