Last active
January 5, 2018 09:17
-
-
Save maxpeterson/be7ab0b754413dc3b22188fda1c0cb6a to your computer and use it in GitHub Desktop.
Copy music folders based on OSX tag
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 | |
colour=$1; shift | |
if test "$colour" == "" ; then | |
echo "Please provide a colour / tag name to search for." | |
exit 1 | |
fi | |
destination=$1; shift | |
if test "$folder" == "" ; then | |
echo "Please provide a destination folder to copy files to." | |
exit 1 | |
fi | |
directory=$1; shift | |
if test "$directory" == "" ; then | |
echo "Please provide a directory to search in." | |
exit 1 | |
fi | |
mdfind -onlyin "$directory" "kMDItemUserTags == '*$colour*'" | while read src; do | |
folder=$(basename "$src") | |
dst="${src/#$directory/$destination}" | |
# map the src | |
#src="${src/#$directory/\/Volumes\/M\/Encoded\/}" | |
rsync -auv "$src" "$dst" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copy all files and folders tagged 'Purple' in
/Volumes/DIRECTORY
to/Volumes/DESTINATION/