Data migration from Sport Tracks (Windows application) to Strava

The Sport Tracks windows application allows exporting all activity data in GPX format. You can select the activities to be exported in activity view and then select export and GPX from the menu bar on the left.

Unfortunately, all activties will be exported into a single GPX file. Strava on the other hand needs a single activity per file to be able to import GPX data.

For this reason, I’ve written a small bash script that can split the single export file from Sport Tracks into many files containing just one activity for importing in Strava.

Here is the script:

head -3 "$input" >/tmp/header
mkdir -p files 2>/dev/null
cd files
rm -f xx[0-9][0-9[0-9][0-9] [0-9].gpx
csplit -n 4 "../$input" '/^ /' '{}'
for f in $(echo xx*)
     [[ $f == xx0000 ]] && continue
     echo "Creating $newf from $f"
     cp xx0000 $newf
     cat $f >>$newf
     echo "" >>$newf
     rm -f $f

In order to run it, you need to replace the value of the input variable by the filename of your Sport Tracks. The script runs under any flavour of Linux (I used Ubuntu 16.04), probably (I didn’t test it) under Windows Subsystem for Linux as well.

The result will be a directory called „files“ containing a separate GPX file for each activity contained in the Sport Tracks export that can be imported to Strava (up to 25 files at a time) through their web interface right away.