The last piece of my new camera kit arrived today and I was eager to try it out. The AGL 3080 GPS Unit is a small device designed for geotagging your photos. When you’re head out on a photo walk, you flip it on, throw it in your bag and go about your business. When you get home and dump your pictures, you use special software to link the timestamps on the photos with the GPS “trail” of information and the photos are magically tagged precisely with where they were taken.

To do this magical feat, I use Jeffrey Friedl’s Geoencoding Plugin for Lightroom. However, this makes the process even more difficult. The reason for this is that the plugin wants the data in GPX format, which is XML based, and the AGL 3080 logs all of it’s data in NMEA format.
Luckily, there is a great command line utility called GPSBabel that will convert the files from a whole bunch of different formats into a whole bunch of other formats. As a bonus, GPSBabel is in Homebrew, so it was stupid easy to install.
So, this got me to thinking – it would be really sweet if I could plugin in the AGL, have it pull the files off automatically, convert them to GPX format, and unmount the device. I knew that it was all possible to do that in a shell script.
But, what would be really cool is if I could get it to it all automatically as soon as the AGL is plugged in. Even though I never used Folder Actions before, I had a vague idea that it was possible to fire a script or Automator workflow when a directory changes.
This was enough information for me to at least get started.
Enter Automator
Automator is one of those things about a Mac that I should really take advantage of more. To be honest, I’m not totally sure why I don’t. And judging by these incredibly naive attempts at workflows, you’ll most likely agree that I’m very green on this subject.
Create a new Automator workflow. Make it of type Folder Action.

Then create a very basic workflow. I know there’s a better way to do this, but I didn’t feel like messing around. I know enough bash scripting to just do it quickly, but I’m sure someone with Automator skills could do everything this script does in Automator directly.

Basically, I’ve created a shell script that runs first. Take careful note that it ignores the input from the File Action, since I’m dealing with hardcoded paths. Nothing fancy, it looks to see if the directory from the AGL exists, if it does it loops through all the .log files and uses gpsbabel to convert them to GPX format and dump them in a directory under my home dir. The code looks like this:
1 2 3 4 5 6 7 8 9 10 | |
Then, I do a quick hack to look for mounted GPS directory, and feed that into Eject Disk. If I run this directly from Automator, it works perfectly.
Folder Actions
Now for the magical part of it. The basic concept is that we need to link this script to the /Volumes directory as a Folder Action. This is actually very easy, except for the fact that /Volumes is hidden from Finder by default. A quick Googling gave me this code to run from the Terminal:
1
| |
Now it’s very straightforward. Navigate to /Volumes in Finder, right click to Services -> Folder Actions Setup… A popup will come up automatically. Select the Folder Action you saved earlier and you’re set.


Magic! Now I plug it in, wait 5 seconds (wait for the volume to
disappear from the Desktop), and disconnect it again. The files are
waiting in ~/gps-tracks all ready for Lightroom.