Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there a built-in way (WIN7) or third-party utility I can use that will allow me to move the contents of the subfolders of my hundreds of parent folders up one level?

To illustrate:

PARENT1/gallery/filex.jpg
PARENT1/gallery/filey.jpg
PARENT1/gallery/filez.jpg
PARENT2/gallery/filex.jpg
PARENT2/gallery/filey.jpg
PARENT2/gallery/filez.jpg

What I want to do (at a single batch action, not individual per folder) is:

PARENT1/filex.jpg
PARENT1/filey.jpg
PARENT1/filez.jpg
PARENT2/filex.jpg
PARENT2/filey.jpg
PARENT2/filez.jpg

Parents have varying names, but all subfolders have the same name "gallery". Is there any quick and painless way to do this? I have roughly 650+ PARENT folders.

share|improve this question
    
Have you tried renaming tools, eg. AR? –  Endoro May 25 '13 at 11:52
    
You could take the opportunity to learn Microsoft PowersHell. A winner in the Truth In Advertising category! –  HABO May 25 '13 at 13:02

1 Answer 1

up vote 2 down vote accepted

You can have Windows execute the same command for all 650 folders sequentially with a simple for /D loop. Go to the directory containing the parents and execute the following command:

for /D %i in (.\*) do @move %i\gallery\* %i\

Optionally, you can delete the empty 'gallery' folders using `rmdir' without the /S-flag, e.g.:

for /D %i in (.\*) do @(move %i\gallery\* %i\ && rmdir %i\gallery)

For more control over the file operations, you may want to look into robocopy, which is far more advanced than move. Also note that spaces in directory names are often parsed as delimiters. For example, rmdir parent 1 will remove the directories 'parent' and '1', but not 'parent 1'. If your directories contain spaces, use quotes, e.g.:

for /D %i in (.\*) do @move "%i\gallery\*" "%i\"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.