How to Fix Garmin DAT Files after ‘Saving History’ Failure

MS 150 Day 1 9-11-2010

Every now and then, the fabulous Garmin 705 will get screwed up while “Saving History” when plugging into the computer. What’s good is that the data isn’t lost. What’s bad is that it can take some hacking at the internal structure of the file to fix it up.

I’ve put together a quick script that you can run on the files to fix them up. It’s not perfect (it won’t fix the lap data, for example). But it saves the time to stitch the files together by hand. The script is attached, and the instructions to use it are below.  Be warned – it’s a little geeky.

Requirements:

  1. A Windows 7 machine (or a machine that has PowerShell V2 installed on it).
  2. This script file: lapfilefixer.ps1 (Size 3.2 KB)
    To make things easy, download it to your desktop.

PowerShell Setup:

  1. From the Start Menu, search for “PowerShell”. Right click on PowerShell and select ‘Run as Administrator’
  2. Type in the following command and follow the prompt
    Set-ExecutionPolicy remotesigned
    image
  3. Close the Window, you’re done here.

Copy the files from your Garmin:

  1. Locate the .dat files on your Garmin. They will be in the (X:\Garmin\History\Laps) directory. Each of the numbered folders represents a ride, start-to-stop.
  2. Copy the Laps folder onto your computer (for example, onto your Desktop)

Run the Script:

  1. Start PowerShell (From the Start Menu, search for PowerShell, and run it)
  2. Navigate to the folder that contains your Lap*.dat files for the ride you want to fix (for example, C:\Users\Kevin\Desktop\Laps\14)
    cd c:\Users\Kevin\Desktop\Laps\14
  3. From this directory, run the script
    c:\Users\Kevin\Desktop\lapfilefixer.ps1
  4. The output will be in the ‘output.tcx’ file in the same directory.
  5. Import the ‘output.tcx’ file file into SportsTracks or Garmin Training Center, or whatever software you prefer.

End Notes:

I hope this helps you out! It certainly has saved me a bunch of time. Note, I’m not responsible for any data loss or problems that the script causes. I’ll try to help you out if you have questions, but I’m no expert on the file format. I just hacked this together for myself. If you want some really good information, I’ve found the following blog and thread helpful:

7 thoughts on “How to Fix Garmin DAT Files after ‘Saving History’ Failure”

  1. y Kevin thanks for this! I had to make one change to the script. It seems if there is only one lap your script fails at the get-date because of the array reference on datfiles. I took out the [0] and it worked for Laps with just one .dat file.

    Thanks,

    Alex

    1. Glad I was able to help – thanks for the notes on the changes you made. That's a good catch. I've updated the script to take into account single-lap file directories.

      FYI – the correct fix is to declare the $datfiles as an array, and then add the new lap files to it. That way the [0] reference will always work later in the script:
      $datfiles = @();
      $datfiles += get-childitem Lap*.dat | Sort-Object;

  2. Hi Kevin

    just came back from cycling in Austria and for some reason all data is in .dat format. Tried your scrip but get errors.

    I Set ExecutionPolicy; Unblock the script from Properties run the script according to your instructions; get principally 2 errors: Get-content and Get-Date errors…

    The output file was produced but has only generic data: <?xml version="1.0" encoding="UTF-8" standalone="no" ?><TrainingCenterDatabase xmlns="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation="http://www.garmin.com/xmlschemas/TrainingCenterDatabase/v2 http://www.garmin.com/xmlschemas/TrainingCenterDa… Sport="Biking"><Id></Id><Lap StartTime=""><TotalTimeSeconds>0</TotalTimeSeconds><DistanceMeters>0</DistanceMeters><MaximumSpeed>0</MaximumSpeed><Calories>0</Calories><Intensity>Active</Intensity><Cadence>0</Cadence><TriggerMethod>Manual</TriggerMethod>
    </Lap><Creator xsi:type="Device_t"><Name>EDGE705</Name><UnitId>3800084776</UnitId><ProductID>625</ProductID><Version><VersionMajor>3</VersionMajor><VersionMinor>10</VersionMinor><BuildMajor>0</BuildMajor><BuildMinor>0</BuildMinor></Version></Creator></Activity></Activities><Author xsi:type="Application_t"><Name>EDGE705</Name><Build><Version><VersionMajor>3</VersionMajor><VersionMinor>10</VersionMinor><BuildMajor>0</BuildMajor><BuildMinor>0</BuildMinor></Version><Type>Release</Type></Build><LangID>EN</LangID><PartNumber>006-B0625-00</PartNumber></Author></TrainingCenterDatabase>

    Is there an email I could send you a screen shot of the error message please (11 lines).

    Thanks a lot.
    vladimir

  3. I started having this same problem a few days ago i.e. data from a ride appeared to be in the historylaps directory as .dat files, and the process of "Saving History" when plugging the 705 unit into the PC did not result in a history*.tcx file. Consequently, the Garmin Uploader did not recognize any new data.

    [Disclaimer: there was some comment on message boards about an older version of firmware corrupting .tcx files – in my case I was using the latest 3.30 version]

    Solution: In my case the clm.nvm file had grown – not sure of the timeframe. In my case it was up to 450MB. There was only 1.2MB or so of free space on my 705 unit, which I concluded was causing the hiccups with transferring .dat files to .tcx.
    After looking around (and making a backup on the PC) I felt comfortable enough to just delete the file (remembering to empty the trash too, to really free up the space) and the problem went away.
    The clm.nvm file was recreated the next time I booted up, and was only 80KB, which is what people seem to think is the correct size.
    Nobody seems to have a definitive answer as to what the file contains, but my experience so far was no consequence to deleting it. I hope this helps.

    P.S. I did not check by trying this, but it might be possible that a hard reset also clears the garminclm.nvm file. I did not think to try that.
    In my case, just deleting the file from the PC worked a treat.

  4. Hi all
    I read a lot of the problem in different threads. Nothing of all the tipps helps. – Thanks guis. But I wondering, why the problem is suddenly there and why Garmin doesn't fix this problem.

    Maybe the solution is to buy a cheap smartphone with gps?

  5. Hi Kevin

    I found very interesting this post. However the script is not available for download. Is it possible to repost it again? Just went into the problem that my Garmin Edge 705 is recording all the routes in .dat rather than in .tcx. Had done a hardware-reset but still suffering the same problem.
    Thanks in advance

Leave a Reply to kmwoley Cancel reply

Your email address will not be published. Required fields are marked *