Created
February 21, 2015 04:51
-
-
Save dbernheisel/2016d57e529704a5fb5d to your computer and use it in GitHub Desktop.
Flatten a folder hierarchy.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Usage: execute flatten-folders.sh while in the directory you want to flatten. | |
| # This will move all content in subdirectories down to present directory | |
| CURRENTDIR="$( cd "$( dirname "$0" )" && pwd)" | |
| for f in "$CURRENTDIR" | |
| do | |
| parentdir="$(dirname "$f")" | |
| find "$f/" -iname '*.*' -exec mv -v \{\} "$parentdir/" \; | |
| rmdir -v "$f" | |
| done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment