Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sort Dropbox Camera Uploads by EXIF location
#!/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
You can’t perform that action at this time.