Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Batch Folder Creation? 4

Status
Not open for further replies.

drfish

IS-IT--Management
Nov 6, 2002
30
US
I need to make 3,998 folders named "0001" - "3999" what's the best way to do this? I've forgotten most of what I used to know about batch files, but it seems like that knowledge would serve me well right now, any ideas? Thanks!
 
Here you go: name it COUNT.BAT and put it in the dir where you want to create the subdirs.

Usage: count lastnumber

------------------
@echo off
:: by Marcs41
if not [%1]==[] goto Okay
echo Syntax: %0 LastNumber (0 -9999)
goto End

:Okay
if [%2]==[::] goto 2nd time around
if [%3]==[::] goto 3rd time around
if [%4]==[::] goto 4th time around
if [%5]==[::] goto 5th time around
if [%6]==[::] goto 6th time around
%comspec% /e:2048 /c %0 %1 ::

goto End
:2nd time around
for %%v in (0 1 2 3 4 5 6 7 8 9) do call %0 %1 %%v ::
goto End
:3rd time around
for %%v in (0 1 2 3 4 5 6 7 8 9) do call %0 %1 %2 %%v ::
goto End
:4th time around
for %%v in (0 1 2 3 4 5 6 7 8 9) do call %0 %1 %2 %3 %%v ::
goto End
:5th time around
for %%v in (0 1 2 3 4 5 6 7 8 9) do call %0 %1 %2 %3 %4 %%v ::
goto End
:6th time around
echo %2%3%4%5
md %2%3%4%5
if [%1]==[%5] exit
if [%1]==[%4%5] exit
if [%1]==[%3%4%5] exit
if [%1]==[%2%3%4%5] exit
:End
--------------

Enjoy The solution is out there. [morning]
 
Thank you so much! You saved me a TON of time (and frustration), it works great!
 
You're welcome, have fun with it! The solution is out there. [morning]
 
Marcs41,

Thanks for the lesson! Having just played with batch files for years (because I thought what you could do was generally too noddy to be worthwhile), several posts recently (this being best example) have made me think again. Although I don't think any of the syntax is user friendly, I can now see that its possible to do far more than I thought (just reading through your post and working out how it works has helped greatly - I even think I've got a neater solution to the original post now!).
 
Thanks all.
And yes wolluf, there is a shorter and neater solution, but .. if anyone wanted to add a digit, this one is rather simple to follow, the other, 'neater' one isn't. The solution is out there. [morning]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top