Hi I wonder how to do print out a list from 1 to 200 with 3 digit format. I can print from 1 to 200 but dont know how to do the format thing. Please help
FOR /L %%A IN (1,1,200) DO (ECHO %%A)
You have to set a variable with enough zeros on the front, then take the last few characters to give the correct range. Delayed expansion means that the variables used will not be evaluated only once when the do is encountered, but every time the variable is used.
This example will print 1-200
@echo off
setlocal enabledelayedexpansion
for /l %%a in (1,1,200) do (
set test1=00%%a
set test2=!test1:~-3!
echo !test2!
)
@echo off
title Counter
SET /A XCOUNT=0
:loop
SET /A XCOUNT+=1
IF "%XCOUNT%" == "301" (
GOTO end
) ELSE (
IF %XCOUNT% LSS 100 (
IF %XCOUNT% LSS 10 (
echo 00%XCOUNT%
GOTO loop
) ELSE (
echo 0%XCOUNT%
GOTO loop
)
) ELSE (
echo %XCOUNT%
GOTO loop
)
)
:end
pause
I know its lengthy, but hey, it works!