How to count in windows bat files

Filed Under (script) by The Chef on 13-05-2009

Tagged Under : ,

This is a simple way to count form 0 to 1000 using bat files.

@echo off
if [%1]==[] goto NONE
if [%2]==[] goto ONE
if [%3]==[] goto TWO
goto THREE

:NONE
for %%x in (0 1 2 3 4 5 6 7 8 9) do call %0 %%x
goto DONE

:ONE
for %%x in (0 1 2 3 4 5 6 7 8 9) do call %0 %1 %%x
goto DONE

:TWO
for %%x in (0 1 2 3 4 5 6 7 8 9) do call %0 %1 %2 %%x
goto DONE

:THREE
echo %1%2%3
goto DONE

 :D ONE

Leave a Reply