Skip to content

Instantly share code, notes, and snippets.

@jacobsalmela
Created May 10, 2015 20:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jacobsalmela/12f60fde06d1465457dc to your computer and use it in GitHub Desktop.
Save jacobsalmela/12f60fde06d1465457dc to your computer and use it in GitHub Desktop.
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