Skip to content

Instantly share code, notes, and snippets.

@ghotz
Created November 7, 2015 22:42
Show Gist options
  • Save ghotz/9ccba3178d56bbc05a4a to your computer and use it in GitHub Desktop.
Save ghotz/9ccba3178d56bbc05a4a to your computer and use it in GitHub Desktop.
Converts Polar Flow TCX file for Garmin Connect
#
# Removes incorrect data from *.tcx files exported from the Polar Flow
# web site so they can be uploaded to the Garmin web site.
# More info: https://forums.garmin.com/showthread.php?165708-Polar-Flow-TCX-export-to-Garmin-Connect
#
$SourceDir = "C:\Users\Gianluca\OneDrive\Documents\Health\PolarFlow";
$DestinationDir = "C:\Users\Gianluca\OneDrive\Documents\Health\ExportGarmin";
Get-ChildItem $SourceDir -Include "*.tcx" -Recurse |
Where-Object { !(Test-Path (Join-Path $DestinationDir $_.Name)) } |
ForEach-Object {
Write-Host "Processing $($_.Name)";
[xml]$tcx = Get-Content $_.FullName;
$node = $tcx.TrainingCenterDatabase.Author;
if ($node -ne $null) { $node.ParentNode.RemoveChild($node) | Out-Null; };
$node = $tcx.TrainingCenterDatabase.Activities.Activity.Creator;
if ($node -ne $null) { $node.ParentNode.RemoveChild($node) | Out-Null; };
$tcx.Save((Join-Path $DestinationDir $_.Name));
};
@metazeroth
Copy link

I tried this just now, and Garmin Connect didn't accept the file. Any idea why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment