Skip to content

Instantly share code, notes, and snippets.

@gpduck
Created May 23, 2017 03:29
Show Gist options
  • Save gpduck/5d3194bc35f79ec20c46cf69eeee1bee to your computer and use it in GitHub Desktop.
Save gpduck/5d3194bc35f79ec20c46cf69eeee1bee to your computer and use it in GitHub Desktop.
Trim a TCX file from Garmin
$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