# Number Sequential List Generator



## Andrew1515 (May 24, 2010)

Hey guys , I don't do much programming, but need to create a huge list of numbers in a certain format. And not sure where to start or know the proper commands.

I need to create a list of sequential numbers and need it formatted a certain way

00000000
00000001
00000002
to
.
..
...
99999999


Then put all numbers into a plain text file.

If any one can help, I would greatly appreciate it.

Thanks!


----------



## TheOutcaste (Aug 8, 2007)

Welcome to TSG!

Copy the text in the following code block into Notepad.
Save it on the desktop as *NumGen.cmd*. Be sure to change the *Save as Type:* box to *All Files* when saving.

```
[plain]@Echo Off
Set _Output=%UserProfile%\Desktop\Numbers.txt
If Exist "%_Output%" Del "%_Output%"
Set _Last=99999999
Set _PadStr=0000000
Set _Pad=8
Set _Count=0
:_Loop
Set _Tmp=%_PadStr%%_Count%
Call Set _Tmp=%%_Tmp:~-%_Pad%%%
>>"%_Output%" Echo.%_Tmp%
Set /A _Count+=1
If %_Count% LEQ %_Last% Goto _Loop
[/plain]
```
Double click the file to run it. It will create a file named *Numbers.txt* on the Desktop with the numbers inside. This will take several days to run. On my Core 2 duo running at 2.0 GHz, I estimate 6.94 days.
Takes 1 minute to do 10,000 numbers, you want 100,000,000 numbers, so 10,000 minutes, that's 166.67 hours.

The resulting text file will be 953.67 MiB in size, nearly 1 GiB. You'll have a hard time opening it in any editor, it could take several minutes just to open it, assuming the editor can handle files that large.


----------



## Andrew1515 (May 24, 2010)

This response was quick ... TheOutcaste thank you very much for your help, you 
are a machine!. It works perfectly :up::up::up::up::up::up::up::up::up::up::up:


----------



## Squashman (Apr 4, 2003)

Some of that code looks familiar


----------



## Keebellah (Mar 27, 2008)

Hi,
Just me messing around, you could add the following line right after :_Loop


```
:_Loop
TITLE=%_Tmp%
Set _Tmp=%_PadStr%%_Count%
```
This way you can see how far the numebering is, it will slow it down a very little bit but keeps you posted on how far it is in the generation of the list


----------



## TheOutcaste (Aug 8, 2007)

Nor sure I'd consider a 44.5% Slowdown a "very little bit". Adding the title line will increase the run time from 6.94 days to 10.03 days

A better option is to change the title every 100 or 1000 numbers. That only slows it down by 6.55% and 4.55% respectively.

```
:_Loop
Set /A _Display=_Count%%[COLOR=Red][B]1000[/B][/COLOR]
If %_Display%==1 Title %_Tmp%
Set _Tmp=%_PadStr%%_Count%
```
The number in red will control the increment in the Title. When set to 1000, the title is updated approximately every 6 seconds.

Though as it'a been nearly 7 days, it should be just about done


----------



## Keebellah (Mar 27, 2008)

Sorry, I stand corrected about the "a bit slower" , I didn't do any exact timing, but this was just to indicate that a simple visual control to show that somewting is happening wouldn';t be out of place even though you can see the numbers.txt growing.


----------



## TheOutcaste (Aug 8, 2007)

Keebellah, your idea is a good one, always good to have some indication that it's doing something, especially for something that will take days to run.
You wouldn't think it would slow it down that much so I wanted to show some numbers to show how much of an effect it would have. 

Guess I could have worded it a bit better, on re-reading it, it does sound a little harsh. My apologies for that.


----------



## Keebellah (Mar 27, 2008)

Just for another alternative:


```
Public Const cHideWindow = 0, cNormalWindow = 1
Set WSHShell = Wscript.CreateObject("WScript.Shell")       
Set FSO = Wscript.CreateObject("Scripting.FileSystemObject") 
Set EnvVar = wshShell.Environment("Process")
tBestand= EnvVar("USERPROFILE") & "\Desktop\Numbers2.txt"
Set Bestand = fso.createtextfile(tBestand,1)
t = 0
For x = 1 To 10000
	Bestand.WriteLine(Right("00000000" & x,8))
Next
Bestand.close
WScript.quit
```
save is as ??????.vbs and just double click to run or call from a batch file

The above vbs script took less than 2 seconds for a list of 10000
I ran it for 4 minutes and got to 17077872

The batch version started at 20:25 and I stopped it at 21:02 and had reached 00357682

Increase the For x to whatever and you get more.

Wscript is an option


----------



## Keebellah (Mar 27, 2008)

I didn't take it as read, I admit that every tenth of a second is an uneeded extra.
I always avoid screen updating in Excel too and that really shortens the proces timing.


No offense taken


----------



## Keebellah (Mar 27, 2008)

Added a small timer here and it takes 2 seconds for 100000


----------



## TheOutcaste (Aug 8, 2007)

Most anything would be faster than a batch file for something like this. Even if you just output the numbers without the leading zeros, it still takes 35-40 seconds for 10,000 numbers.
I didn't even think to try a VBScript, thanks for posting that. I'll bet Andrew1515 wishes you'd posted that a week ago

Takes 4 seconds on my system for 100,000 numbers though
3 year old Core2 Duo, 2.0 GHz running Win 7 Ultimate x64 with 4 GB RAM


----------



## Keebellah (Mar 27, 2008)

Mine is a Quad Core 2.4 GHz 3 GB RAM and W7 Ultimate X64


----------



## Keebellah (Mar 27, 2008)

I got to using vbs scripts since it's more versatile to program and it really speeds up my work.
I'm still one of the 'old MS DOS trade' but this adds a little extra to the old DOS


----------

