Flatten a Nested Directory & File Hierarchy from Command Line of OS X

Lets say you have this kind of file/folder structure:

master ---- folder1 --- image1.jpg
        |            |
        |            -- image2.jpg
        |
        |
         -- folder2 --- image1.jpg
        |            |
        |            -- image2.jpg
        |
         -- etc.

You can take all the *.jpg file or any file type, and move it into one folder.
Here are the command to use:

cd <root_directory> <-- "where all the file are located"
find * -type f -print0 | xargs -0 -I%%% mv -n %%% ../<new_directory> <-- "new destination folder"

Any Comments?

This site uses Akismet to reduce spam. Learn how your comment data is processed.