Batch count from 0000 till 5000

Microsoft Windows 7 professional
April 23, 2010 at 01:44:07
Specs: Windows 7
Hi,

I need to create a batch that will count from 0000 til 5000. I found this batch batch: http://www.computing.net/answers/pr...

But that one counts from 0 (1 char) and not from 0000 (4 chars)

Please help!


See More: Batch count from 0000 till 5000

Report •

#1
April 23, 2010 at 03:11:20
The following script generates numbers from 0000 to 5000 prefixing each number with the proper amount of zeroes.
So coded it has no practical usage, but obviously you know what you are trying to achieve.


@echo off & setlocal EnableDelayedExpansion
for /L %%j (0 1 5000) do (
  set  n=000%%j
  set n=!n:~-4!
)


Report •

#2
April 23, 2010 at 03:11:35
I created a work-around!

REM 10
if !N! LSS 10 (
ECHO 000%N%>>%shutfile%.bat
goto loop
)

REM 100
if !N! LSS 100 (
ECHO 00%N%>>%shutfile%.bat
goto loop
)

REM 1000
if !N! LSS 1000 (
ECHO 0%N%>>%shutfile%.bat
goto loop
)


Report •

#3
April 23, 2010 at 03:12:05
Thanks Ivo! Thats a lot better!

Report •

Related Solutions

#4
April 23, 2010 at 03:28:06
Result:

@ECHO OFF & SetLocal EnableDelayedExpansion
for /L %%j in (0 1 5000) do (
set n=000%%j
set n=!n:~-4!
cscript.exe //nologo SampleShutdown.vbs PC!N!
)

It works perfectly, thanks again!


Report •

Ask Question