Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Number List Text File Creator
#1
Not sure if this will help anyone out, but I was fooling around with simple loops in batch and had this code at some point so I might as well share it.

Code:
@echo off
title List Creator v1.0 - Ace
set i=1
if exist file.txt goto exist

:start
if %i% GTR 100 goto end
echo %i%. > file.txt
set /a i+=1
goto start

:exist
echo The file already exists... Press any key to exit
pause>nul

:end
exit

If you run it, it will create a file named "file.txt" in the same location you ran the batch script. The file.txt will contain an empty number list template for you with however many numbers you want if you edit the "100" in my code here:

Quote:if %i% GTR 100 goto end

If file.txt exists in the same directory as the batch script it will not create a new file or add on to the original, and the script will exit, in case you happen to coincidentally have a file named file.txt with content that you don't want to replace or overwrite.

Note: I've had it up to 10000 for the value, don't use commas (ex: 10,000) or spaces (ex: 10 000) though. Just remember the higher the value, the more time it will take. It took me about a minute or so to create a file with 10000 numbered lines, but it depends on your system specs as well. A good safe number to have is around 1000.
Reply
#2
I haven't been experimenting much with batch, but this looks like it could come in handy. Thanks for sharing it Ace.
Reply
#3
No problem, if you have to generate a huge list template you can modify it to generate a list in any kind of format.

For example even:
Code:
Item # 1)
Item # 2)
Item # 3)
Item # 4)
Item # 5)

That kind of format is possible for automatic generation if you modify this a bit.
Reply
#4
Oh, ok. I see what you mean. I'll be looking into it. Thanks again.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)