Batch FIle for Directory looping

H

Holden Caulfield

Hi there!
I need a working batch file that:

1.Takes the current directory it is run from and loops through each
exisiting folder
2.in doing so creates 2 new subdirectories in each existing directory

So, if I run the batch file in c:/apples, which has these
subdirectories, grannysmith, macinstosh and golden_delish, 2
subdirectories are created in each of the apple types.

That's It!
(But just in case you want more info, here it is...)

Background: I am using a PNG to JPG converter to literally convert
thousands of PNGs to JPGs in thousands of different directories, and
need to automate the process. The images are converted and saved into
2 subdirectories because they are resized to two different sizes as
well.

I know I want to sort of combine a DIR command with a FOR LOOP
command, and then create the subdirs (and run my command line
converter), but I don't know how toprogram batch files that well, and
I need to get this thing done ASAP. I searched for the last two hours
on a resource that does this (I think) simple requirement, but to no
avail.

I appreciate any and all help. Especially a working batch file! ;)

Thanks,
Holden
 
P

Pegasus \(MVP\)

Holden Caulfield said:
Hi there!
I need a working batch file that:

1.Takes the current directory it is run from and loops through each
exisiting folder
2.in doing so creates 2 new subdirectories in each existing directory

So, if I run the batch file in c:/apples, which has these
subdirectories, grannysmith, macinstosh and golden_delish, 2
subdirectories are created in each of the apple types.

That's It!
(But just in case you want more info, here it is...)

Background: I am using a PNG to JPG converter to literally convert
thousands of PNGs to JPGs in thousands of different directories, and
need to automate the process. The images are converted and saved into
2 subdirectories because they are resized to two different sizes as
well.

I know I want to sort of combine a DIR command with a FOR LOOP
command, and then create the subdirs (and run my command line
converter), but I don't know how toprogram batch files that well, and
I need to get this thing done ASAP. I searched for the last two hours
on a resource that does this (I think) simple requirement, but to no
avail.

I appreciate any and all help. Especially a working batch file! ;)

Thanks,
Holden

Try this:

@echo off
for /d %%a in (*.*) do md "%%a\one" & md "%%a\two"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top