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 fanatic 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 geocoordinates. After some checks for parameter and exiftool installed it reads the geocoordinates 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.
2 # Originally written by smokey01 28 May 2017
3 # Rewritten for OSX by Eric Buijs 9 Jan 2019
4 if [ $# -eq 0 ]
6 echo You need to specify a file.
7 echo EG: place photo.jpg
8 exit 1
11 if [ ! -d /usr/local/Cellar/exiftool ]
13 echo “This script requires exiftool!”
14 exit 1
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