To kick off the year I started to learn Bash scripting, something I wanted to do a very long time. I humbly began with tutorials on the web like this one and I’m rewriting scripts from Smokey01, a Puppy Linux user. As an exercise I simply rewrote this script to work on OSX. If you want to use it you need to install exiftool. I installed exiftool with Homebrew and typed brew install exiftool but there’s also a dmg file available. If you don’t use Homebrew you do have to change the check if exiftool is installed.
Now for the script. It reads a jpeg file that must contain geo-coordinates. After some checks for parameter and exiftool installed it reads the geo-coordinates and stores them in the variable coord. This variable is then added to a Google search query and the result displayed in the browser.
Save the script e.g. with the name place and run with place /path/to/photo.jpg to display the location where photo.jpg was taken.
1 #!/bin/bash 2 # Originally written by smokey01 28 May 2017 3 # Rewritten for OSX by Eric Buijs 9 Jan 2019 4 if [ $# -eq 0 ] 5 then 6 echo You need to specify a file. 7 echo EG: place photo.jpg 8 exit 1 9 fi 10 11 if [ ! -d /usr/local/Cellar/exiftool ] 12 then 13 echo "This script requires exiftool!" 14 exit 1 15 fi 16 17 coords=`exiftool -n -p '$GPSLatitude,$GPSLongitude' $@` 18 read -e -p "Do you want to see the location in your Browser? " choice 19 [[ "$choice" == [Yy]* ]] && open https://www.google.com/search?q=$coords || exit 1