Here is perhaps the most useful of the three, fit_split_on_gaps, which finds gaps of some specified minimum duration (default 8 hours, or otherwise specified with the -tgap option) and splits the FIT data into multiple sub-files at any gaps found which meet or exceed this threshold.
This and the other codes can be found here, on Google Docs.
It's fairly common in my experience to forget to "reset" my Garmin between activities, despite having set it to warn me at the start of a ride if I have not. GoldenCheetah, for example, contains some nice code to deal with this problem, allowing rides to be split at selected gaps. However, since I've not been using a power meter since last summer, I've been using Strava a lot more than GoldenCheetah. And Strava lacks and ride-splitting capability.
Enter fit_split_on_gaps. Its default behavior is to take each FIT file and, if it finds any gaps between meaningful data (ignoring the "power down" and "power up" records which sometime pollute idle periods), it partitions the original file into sub-files, naming each according to the Garmin convention of "yyyy-mm-dd-hh-mm-ss" with a "_split.fit" suffix (although the suffix can be changed) in the same directory. Alternately the files can be written to a separate directory with or without (default) a suffix.
There's a few options. The most important is "-h" which prints help. I won't try and describe the other options, as the code may still be modified and these may change. However, so far there's two primary modes:
- To take one or more input file, and produce output files (by default only if gaps are found) of individual segments.
- To write one file, or standard input, to standard output, retaining only one segment, and discarding the others
The project took longer than I expected, and honestly I wonder how robust it is. Presently I assume every record without a time stamp is a "definition" and should be included in each split file. So these are always written. Records with time stamps are included in a given file only if the record falls between the gaps which delimit the segment. It's assumed the records are in chronological order, so if gaps are found, everything in between is written to the same file (assuming it's not discarded as a "fragment").
Thanks again to Kiyokazu Suto for doing such nice work on Garmin::FIT.