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]


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


One response to “Instantly Flatten A Directory In OS X With A Terminal Command”