Batch file needed to combine all subdirectories to one

phone_tech

Honorable
Jan 2, 2013
1
0
10,510
I am need of help and saw some good ones on here but not specific to what i need to acomplish. I have a folder on my D:\ drive (clients) that contains around 3,000 or so other folders (client names). in those folders the files and folders can be completely random.

i am trying to create a batch file to take all of the subfolders and files that are in the individual client names folders and combine them all into one new folder within the client names folders.

Any help out there? i havn't done much with bat files other than for reporting file types of these same folders and also mapping network drives.

thanks,
J
 

Scott_D_Bowen

Honorable
Nov 28, 2012
50
0
10,590
Funnily enough because of a very old annoyance with PKZIP and PKUNZIP you can do just this.

Use PKZIP to ZIP each folder, inclusive of everything to a given location.
Then use PKUNZIP to extract the contents of the ZIP --- without preserving the folder (directory and sub-directory) hierarchy.

So long as you have the free space for each ZIP that gets created this is by far the easiest solution, as batch files don't really handle unknown folder names without some really funky capturing of those names and processing them using methods that, frankly, are more dangerous (by far) than what I've proposed.