Created
May 23, 2017 03:29
-
-
Save gpduck/5d3194bc35f79ec20c46cf69eeee1bee to your computer and use it in GitHub Desktop.
Trim a TCX file from Garmin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$InPath = "c:\activity.tcx" | |
$OutPath = "c:\activity_trimmed.tcx" | |
$x = [xml](get-content $InPath) | |
$x.TrainingCenterDatabase.activities.Activity | %{ | |
$Activity = $_ | |
$Activity.lap | %{ | |
$Lap = $_ | |
$lap.track | %{ | |
$Track = $_ | |
$Track.TrackPoint | ?{[datetime]$_.Time -gt [datetime]"2017-05-18T02:26:34.000Z"} | %{ | |
$Track.RemoveChild($_) | |
} | |
} | |
if($lap.track.ChildNodes.Count -eq 0) { | |
$Activity.RemoveChild($Lap) | |
} | |
} | |
} | |
$x.save($OutPath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment