Digg It! Slashdot It! Delicious It!
This example shows you how to count in a .bat or .cmd batch file script. This can be useful for many things.
BatchCounter.bat
@echo off set StopAt=999 @echo. @echo **** I will now count to %StopAt%! **** @echo ?? Are you Ready ?? @echo. pause :start if [%N0%]==[] set N0=0 if [%N1%]==[] set N1=0 if [%N2%]==[] set N2=0 if [%N3%]==[] set N3=0 :N0 if %N0%==9 goto N1 if %N0%==8 set N0=9 if %N0%==7 set N0=8 if %N0%==6 set N0=7 if %N0%==5 set N0=6 if %N0%==4 set N0=5 if %N0%==3 set N0=4 if %N0%==2 set N0=3 if %N0%==1 set N0=2 if %N0%==0 set N0=1 goto count :N1 set N0=0 if %N1%==9 goto N2 if %N1%==8 set N1=9 if %N1%==7 set N1=8 if %N1%==6 set N1=7 if %N1%==5 set N1=6 if %N1%==4 set N1=5 if %N1%==3 set N1=4 if %N1%==2 set N1=3 if %N1%==1 set N1=2 if %N1%==0 set N1=1 goto count :N2 set N1=0 if %N2%==9 goto count if %N2%==8 set N2=9 if %N2%==7 set N2=8 if %N2%==6 set N2=7 if %N2%==5 set N2=6 if %N2%==4 set N2=5 if %N2%==3 set N2=4 if %N2%==2 set N2=3 if %N2%==1 set N2=2 if %N2%==0 set N2=1 :count @echo %N2%%N1%%N0% if %N2%%N1%%N0%==%StopAt% goto end if %N2%%N1%%N0%==999 goto error goto start :error @echo !!!! Done Counting! @echo I can only count to 999 unless you modify me do more !!!! pause goto exit :end @echo !!!! Done counting to %N2%%N1%%N0% !!!! Pause :exit @echo Good Bye!