I just finished another bit of terminal foo and dropped it into a script in /usr/local/bin for easy execution. The problem I'm trying to solve is that my GPS logger creates .log files which are NMEA sentence format. Which no geotagging application will read. So initially I used
GPS Babel to convert, but that's a rather tedious business, especially if I have a large number of logs.
Fortunately, gpsbabel, on the Mac at least, comes with as both a GUI and a commandline program. Enter the terminal. I order my logs in a subdirectory structure that looks like this:
2008/11/
2008/12/
2009/01/
2009/02/
You get the drift. So I copy all this months logs into 2009/09/ and convert them to gpx. Tomorrow I copy some more logs in. Now I have some logs and their gpx versions, and some logs that still need to be converted. The following takes care of that:
Code:
#!/bin/bash
cd ~/Pictures/GPS_logs/`date +%Y`/`date +%m`
for i in `find . -type f -iname '*'.log`; do log=`echo $i | sed 's/.log/.gpx/'`; if [ ! -f $log ]; then gpsbabel -r -t -w -i nmea -f $i -o gpx -F $log; fi done
The first line changes to the directory for the current year/month. The second finds all .log files and checks if there is a corresponding .gpx file. If there isn't, it calls gpsbable to make one.
This is not a difficult script, it just took a bit of fiddling to get the syntax right. What used to take me anything from a few minutes to several hours and a lot of RSI inducing mousing, not takes me a few seconds.
The ultimate goal is to develop it further so that it will copy anything from the GPS logger that isn't already on the computer, put it in the correct directories (create them if they don't exist), and convert the logs that need converting. Then hook it up to automator so this happens automatically each time I plug in the GPS logger.