Automated batch conversion of Garmin FIT files to GPX in Windows

Whilst working on a project to output the elevation chart of a GPX track I came across some code to produce your own heatmap from a bunch of gps tracks. I thought that'd be pretty cool to visualized my own as I've been using Strava's global heatmap since it was released in 2017 to plot mountain bike routes. I was pretty bummed that when they were released, personal heatmaps were a premium feature so it got me thinking I may have a tinker at that.

Anyway, side-tracked as ever I embarked on seeing if I could download all my routes from Garmin Connect (which you can here). It didn't take long for them to arrive, but on inspecting them realised they were all in .fit format (of course they were proprietary Garmin!).

I knew GPS Babel was probably going to be the answer for converting the files as I'd used it waay back in the day but wasn't sure if it could natively batch process files, a quick bit of research said no, but no matter should be easily be able to knock a simple command together.

I was on my Linux box at the time so I wasn't so wasn't looking for a windows solution but I did note that there wasn't really any tutorials out there for it only this method which seems way too manual for my liking, so I thought in the spirit of giving back (and a bit if site traffic!) if dig out my windows batch fu from the recesses of my brain and post one:

You'll need to have GPS Babel already installed then just simply open the command prompt in the folder where the .fit files are and fire out this line of script:

Windows command line code

for %i in (*.fit) do "C:\Program Files\GPSBabel\gpsbabel.exe" -rt -i garmin_fit -f %i -x track,course,speed -o gpx -F %~ni.gpx

should be good to go and it quickly chewed through the 37,652 files I downloaded from Garmin!

Windows batch code

For an easier method which doesn't use the command line at all, just right-click in the folder where the files are located, fire out a New Text Document, open it and paste the following code:

@echo off
Title Batch convert fit to gpx
for %%i in (*.fit) do "C:\Program Files\GPSBabel\gpsbabel.exe" -rt -i garmin_fit -f %%i -x track,course,speed -o gpx -F %%~ni.gpx && echo %%i converted to %%~ni.gpx
pause

then just save the file as convert.bat then double click on it :-). Note there's an extra % used in the batch command to escape the other %.

Extra credit

There's a bit of extra credit in there as it turns the prompt off and lists the converted files. If you want some double extra credit you can hop on over to my Github page and the code the will colour the output as well:

If you are feeling brave you can append && del %%i onto the end and it will delete the converted files as well.

Tags : garmin fit gpsbabel convert batch windows

Search Posts

Back to top