Batch loop through folders copying contents

November 13, 2009 at 04:56:31
Specs: Windows Vista
I'm a complete newb when it comes to batch
programming and am struggling to do
something that's probably very simple...

I have a load of files in a set file structure and I
want to copy out the contents of certain sub-
folders into another folder. The file structure
looks something like this:

c:\myimages\producta\bigimages\
c:\myimages\producta\smallimages\
c:\myimages\productb\bigimages\
c:\myimages\productb\smallimages\

etc

What I want to do is copy everything from:

c:\myimages\*\bigimages\

to:

c:\allthebigimages\

but as I can't seem to use wildcards in paths I
figured I need to do a loop - at which point I get
stuck.

So how do I write a batch that loops through
all the 'product' folders and copies everything
from the 'bigimages' sub-folder?

Thanks!

John


See More: Batch loop through folders copying contents

Report •


#1
November 13, 2009 at 06:28:53
for /d %%a in ("c:\myimages\*") do @copy "%%~Fa\bigimages\*" "c:\allthebigimages\" 2>NUL


Report •

#2
November 13, 2009 at 06:40:07
That appears to work. Fantastic! Many thanks!!!

Report •

Related Solutions


Ask Question