How to increment variable under DOS?

前端 未结 9 1643
清酒与你
清酒与你 2021-02-06 21:36

I\'ve spent the past 3hrs trying to work this out but just couldn\'t find a solution. Here\'s my batch script:

if NOT Exist Counter.txt GOTO START
Type c:\\count         


        
9条回答
  •  既然无缘
    2021-02-06 22:10

    Indeed, set in DOS has no option to allow for arithmetic. You could do a giant lookup table, though:

    if %COUNTER%==249 set COUNTER=250
    ...
    if %COUNTER%==3 set COUNTER=4
    if %COUNTER%==2 set COUNTER=3
    if %COUNTER%==1 set COUNTER=2
    if %COUNTER%==0 set COUNTER=1
    

提交回复
热议问题