Created
December 27, 2013 00:44
-
-
Save ybv/8140873 to your computer and use it in GitHub Desktop.
A script to move folders containing .mp3 files to user's own music folder. Often, downloaded music on my mac rests in downloads, thought this would be handy to move all of them at once.
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
| #!/usr/bin/nv bash | |
| directory=$PWD | |
| dot="." | |
| ddot=".." | |
| myarray=(`find $directory -type f -name "*.mp3"`) | |
| if [ ${#myarray[@]} -gt 0 ]; then | |
| for name in ${myarray[@]}; do | |
| if [[ "$(dirname $name)" != "$dot" ]]; then | |
| rsync -aq --progress $(dirname $name) "/Users/ybv/music" | |
| fi | |
| done | |
| for name in ${myarray[@]}; do | |
| if [[ "$(dirname $name)" != "$dot" ]]; then | |
| if [[ "$(dirname $name)" != "$ddot" ]]; then | |
| rm -rf $(dirname $name) | |
| fi | |
| fi | |
| done | |
| else | |
| echo false | |
| fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment