0

I dont know what I am doing wrong here. But I am trying to increment "Counter"

Code is supposed to loop backwards through 1000 then every 10 pause for 30 seconds. I can't seem to get the COUNTER to work though. There are a dozen Stack Overflows about this but I still can't figure out my mistake here

set counter=0

FOR /L %%G IN (1000,-1,1) DO (
    set /a "counter=%counter%+1"
start otherscript.cmd %%G
    echo For %%G
    echo Counter %counter%
        if %counter% ==10 (
        set /a counter=0
        timeout 30
        )
    )
Cade
  • 123
  • 1
  • 10
  • I am kicking myself in the head over this issue. This still only results in a 1 instead of a Zero constantly and now I get a missing operator at the end, not sure what thats about 'setlocal enabledelayedexpansion set !counter!=0 FOR /L %%G IN (40298917,-1,1) DO ( set /a !counter!=%counter%+1 echo For %%G echo Counter %counter% pause if !counter! ==10 ( set /a counter=0 timeout 30 ) ) ' – Cade Mar 26 '21 at 18:28
  • 1
    Use this: `set /a "counter+=1"` and `if "!counter!"=="10"` – Squashman Mar 26 '21 at 18:38

0 Answers0