Created
May 10, 2015 20:09
-
-
Save jacobsalmela/12f60fde06d1465457dc to your computer and use it in GitHub Desktop.
Sort Dropbox Camera Uploads by EXIF location
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 | |
apiKey="abcD12345efGhIJkLmn-abcD12345efGhIJkLmn_cO_8" | |
filename=$(basename "$1") | |
filename="${filename%.*}" | |
directoryname=$(dirname "$1") | |
latitude=$(mdls "$1" | awk '/Latitude/ {print $3}') | |
longitude=$(mdls "$1" | awk '/Longitude/ {print $3}') | |
data=$(curl -s https://maps.googleapis.com/maps/api/geocode/json?latlng="$latitude","$longitude"&key="$apiKey") | |
city=$(echo "$data" | grep "formatted_address" | head -1 | cut -d',' -f2 | sed -e 's/^[ \t]*//') | |
case "$city" in | |
"New York City") mv "$1" ~/Dropbox/Pictures/New\ York\ City/; | |
/usr/local/bin/terminal-notifier -title "$filename Sorted" -subtitle "Moved Automatically" -message "Into $directoryname";; | |
"Minneapolis") mv "$1" ~/Dropbox/Pictures/Minneapolis/; | |
/usr/local/bin/terminal-notifier -title "$filename Sorted" -subtitle "Moved Automatically" -message "Into $directoryname";; | |
"San Fransisco") mv "$1" ~/Dropbox/Pictures/San\ Fransisco/; | |
/usr/local/bin/terminal-notifier -title "$filename Sorted" -subtitle "Moved Automatically" -message "Into $directoryname";; | |
*) echo "City not found";; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment