Asif
Asif

Reputation: 29

Error in batch file "..unexpected at this time batch file"

I have a code in a batch file which is giving an error:

56 was unexpected at this time

at if condition (if %fileSize% == 9363)

My code is:

for %%F in ("site_data.csv") 

   do set "fileSize=%%~zF" 

   if %fileSize% == 9363 
   (
      pause
      set sum2=%TIME:~3,2% 

      echo sum2=%sum2%
      pause

      if /f %sum2% gtr %sum1% 
      (
         goto :p3
      )

      goto :p2
   )

I don't understand what is the problem?

Upvotes: 2

Views: 1680

Answers (1)

ElektroStudios
ElektroStudios

Reputation: 20464

The "/F" parameter doesn't exist, please see the command help:

IF /?

And SUM1 variable doesn't exist in the example code that you given, so that can be another problem.

Try this:

@Echo OFF
for %%F in ("site_data.csv") do (set "fileSize=%%~zF") 

IF %fileSize% EQU 9363 (set /A sum2=%TIME:~3,2%)
if %sum2% gtr %sum1% (goto :p3) ELSE (goto :p2)

Upvotes: 2

Related Questions