You are not logged in.
Pages: 1
Hello,
I'm very interested by this topic: Extract date from a GPX file
Is there a way to take the second <time> tag, not the first one?
In my files the first <time> tag is the date of the file, not the date of the day that the activity occurs.
I put a sample file in attached.
987541786-gpx.txt
Can you help me please?
Regards
Offline
You can use a Pascal Script rule to extract the second <time> tag from a GPX file.
The content will be inserted as is into the filename, e.g. "2014-08-24T05:21:45Z", so you'll have to clean it up a bit to you liking, with other rules perhaps.
var
Content: WideString;
Matches: TWideStringArray;
begin
if (Length(FilePath) > 0) and WideFileExists(FilePath) then
begin
Content := FileReadText(FilePath);
Matches := SubMatchesRegEx(Content, '<time>.*?</time>.*?<time>(.*?)</time>', False);
if Length(Matches) > 0 then
FileName := Matches[0] + ' ' + FileName;
end
end.
Offline
It seems to be the character ":" that is guilty. This character is not allowed for file names.
How can I sol the pb?
Last edited by Toto Lembrouille (2025-02-12 07:10)
Offline
I finally solve my problem by adding another rule to replace ":" by "-".
Offline
Pages: 1