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
--------------
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.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.