Instantly Flatten a Directory in OS X with a Terminal Command

Instantly Flatten a Directory in OS X with a Terminal Command

Sometimes we all go a little too nuts on making folders inside of folders and you just need to flatten the whole thing down to one. OS X Daily shows off a handy Terminal command for just that.

When you have directories inside of other directories, you end up losing track of files pretty quickly. To smash the whole thing down into one directory, a simple Terminal command is all you need. In this example, TargetDirectory is the subdirectory you want to move the contents from:

find TargetDirectory/ -mindepth 2 -type f -exec mv -i '{}' TargetDirectory/ ';'

With that, all the files located in TargetDirectory will be moved up into the higher directory. Head over to OS X Daily for a few more examples of how it works.

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


via Lifehacker
Instantly Flatten a Directory in OS X with a Terminal Command