Author Topic: [Tasker] Remove timestamps from GPX files  (Read 930 times)

Offline tapio

  • Expert
  • Master of Locus
  • ****
  • Posts: 861
  • Thanked: 176 times
    • View Profile
[Tasker] Remove timestamps from GPX files
« on: November 14, 2021, 18:09:56 »
With the following Tasker task you can remove all timestamps from GPX files, a privacy option. Locus does only export GPX with timestamps.
Backup your files. It's not too thoroughly tested.

https://taskernet.com/shares/?user=AS35m8kdDIMDeveQcQfRglam%2Fah1mTW%2FWcg05FZ39c0i1q%2F77iY3E7cIwxCkXqJTaTA%3D&id=Task%3ARemoveTimestampsGPX
« Last Edit: November 15, 2021, 10:37:36 by tapio »
LM4 USER ID: 1AACAFF2A2
 
The following users thanked this post: Andrew Heard, ColdAutumn, lor74cas

Offline Andrew Heard

  • Expert
  • Professor of Locus
  • *****
  • Posts: 1056
  • Thanked: 100 times
  • Country: 00
    • View Profile
  • Device: Samsung Galaxy A5 v8.1, Samsung Tab A7 v10
Re: [Tasker] Remove timestamps frim GPX files
« Reply #1 on: November 14, 2021, 22:01:57 »
I see the main processing is done via the line
Code: [Select]
sed -i -z 's;[\s\t]*&lt;time&gt;[^&lt;]*&lt;/time&gt;[^&lt;]*;;g' '%file'</Str>very clever. Thanks for sharing @tapio.
LM4.9.1 GOLD user ID:142d400c7
 

Offline ColdAutumn

  • More than Newbie
  • *
  • Posts: 61
  • Thanked: 2 times
    • View Profile
  • Device: Samsung Note 8
Re: [Tasker] Remove timestamps from GPX files
« Reply #2 on: January 03, 2022, 08:19:12 »
With the following Tasker task you can remove all timestamps from GPX files, a privacy option. Locus does only export GPX with timestamps.
Backup your files. It's not too thoroughly tested.

https://taskernet.com/shares/?user=AS35m8kdDIMDeveQcQfRglam%2Fah1mTW%2FWcg05FZ39c0i1q%2F77iY3E7cIwxCkXqJTaTA%3D&id=Task%3ARemoveTimestampsGPX

Do we need to install another app?
Sorry and many thanks.
 
The following users thanked this post: tapio

Offline tapio

  • Expert
  • Master of Locus
  • ****
  • Posts: 861
  • Thanked: 176 times
    • View Profile
Re: [Tasker] Remove timestamps from GPX files
« Reply #3 on: January 03, 2022, 10:26:37 »
Yes, this is a Tasker script. Tasker is an Android automation app. Look for it in the PlayStore.
« Last Edit: January 03, 2022, 10:32:07 by tapio »
LM4 USER ID: 1AACAFF2A2
 

Offline lor74cas

  • Expert
  • Padavan of Locus
  • ***
  • Posts: 424
  • Thanked: 72 times
  • Country: it
    • View Profile
  • Device: Samsung A5 2017
Re: [Tasker] Remove timestamps from GPX files
« Reply #4 on: January 07, 2022, 10:50:03 »
I see the main processing is done via the line
Code: [Select]
sed -i -z 's;[\s\t]*<time>[^<]*</time>[^<]*;;g'
Thx. Yeah, even if you're good at regex, sed is always tricky; it's especially the CRLF treatment of it, so I was happy about the -z option. Took me a while. The greedy matching of regex and multiple occurences of the same tags is also a thing always...
Just wanted to create a basic task. GPX files sometimes differ, e.g. some apps create a more flat output with nested xml tags and one trkpt per line...

Your next posting will be #1000 :)
Hello tapio,
I am recently trying to improve my knowledge of regexp and I would like to understand a couple of things about your method.
You have chosen to replace the text with null instead of deleting the row, for what reason?
The search for the entire line containing the time tag would be done with:
^ \ s * <time. * / time> $
while you use
[\ s \ t] * <time> [^ <] * </time> [^ <] *
\ s should ensure that both spaces and tabs are captured
then I see that you wanted to exclude any internal and external tags with [^ <], but I have not found any gpx exported from locus with these characteristics.
Mine is not a criticism, I'm just trying to understand why you made these choices out of pure curiosity and desire to learn.
Locus Map 4
Locus Map for Garmin
Locus Tasker
Geocaching4Locus
 

Offline tapio

  • Expert
  • Master of Locus
  • ****
  • Posts: 861
  • Thanked: 176 times
    • View Profile
Re: [Tasker] Remove timestamps from GPX files
« Reply #5 on: January 07, 2022, 11:35:23 »
Ugh, I need to look again. Just some related thoughts I hope:

a) I didn't only have Locus GPX in mind. Some other apps were in use as well, they create different xml formats. Replace with NULL? Do I leave an ugly empty line? May need to look at it again.
b) time xml tag may be stretched over multiple lines.
c) I think with the exclusion of the bracket I prevented greedy matching. Keep in mind Regex matches greedy. a.*b matches until the last "b": 1234abcdgebabbbgggchbdkj - i.e. in GPX it would match from first <time> until the last </time> it can find. This would effectively delete most of the gpx - this is also because sed -z in a way flattens the whole file to one line (otherwise, in the default line-by-line style of sed, regex wouldn't work for xml tag structures IMO)
d) As for the tab I probably was just lazy to look into docs, wasn't sure about it being included in \s, thanks for the info
« Last Edit: January 07, 2022, 11:46:46 by tapio »
LM4 USER ID: 1AACAFF2A2
 

Offline lor74cas

  • Expert
  • Padavan of Locus
  • ***
  • Posts: 424
  • Thanked: 72 times
  • Country: it
    • View Profile
  • Device: Samsung A5 2017
Re: [Tasker] Remove timestamps from GPX files
« Reply #6 on: January 10, 2022, 17:30:27 »
Ugh, I need to look again. Just some related thoughts I hope:

a) I didn't only have Locus GPX in mind. Some other apps were in use as well, they create different xml formats. Replace with NULL? Do I leave an ugly empty line? May need to look at it again.
b) time xml tag may be stretched over multiple lines.
c) I think with the exclusion of the bracket I prevented greedy matching. Keep in mind Regex matches greedy. a.*b matches until the last "b": 1234abcdgebabbbgggchbdkj - i.e. in GPX it would match from first <time> until the last </time> it can find. This would effectively delete most of the gpx - this is also because sed -z in a way flattens the whole file to one line (otherwise, in the default line-by-line style of sed, regex wouldn't work for xml tag structures IMO)
d) As for the tab I probably was just lazy to look into docs, wasn't sure about it being included in \s, thanks for the info
a) I understand, I associate gpx with locus without thinking that there are other apps  :D
Replace with NULL? sed -i -z 's;[\s\t]*<time>[^<]*</time>[^<]*;;g' sed 's for substitution; regexp for search; text to replace with; g greedy operator' the null in this case is between ;;
b) do you have an example?
c) so you use this method because of the -z parameter, this part is also not clear to me, do you have a file example for which the -z parameter is needed?
Never using the -z parameter makes it harder for me to interpret your regexp, do you have an example file that made it necessary for you to use it?
d) Sometimes being a beginner like me is an advantage because without documentation you do nothing  ;D

Thanks for the comprehensive answers, you are very kind as always

Locus Map 4
Locus Map for Garmin
Locus Tasker
Geocaching4Locus
 

Offline tapio

  • Expert
  • Master of Locus
  • ****
  • Posts: 861
  • Thanked: 176 times
    • View Profile
Re: [Tasker] Remove timestamps from GPX files
« Reply #7 on: January 10, 2022, 18:58:25 »
b) As for the time tag, it is unlikely that it is spread over 3 lines. Just possible. It's just in oder to be safe. In another script, I delete trkpt tags. Those are most likely spread over multiple lines.
c) That's the point. -z kind of flattens to one line. Allowing analysis over (in the source) multiple lines. Usually sed operates per line. Then you can not match from xml tag start to xml tag end if tag start and tag end are in multiple lines.
LM4 USER ID: 1AACAFF2A2
 
The following users thanked this post: lor74cas

Offline 0709

  • Apprentice of Locus
  • **
  • Posts: 112
  • Thanked: 49 times
    • View Profile
    • Locus track navigation
  • Device: THL4000 CM12.1 (A5.1.1) MI A2 Lite (A9)
Re: [Tasker] Remove timestamps from GPX files
« Reply #8 on: January 10, 2022, 19:22:20 »
Learn & understand Tasker ?
Fine. Roger.

Remove gpx timestamps ?
Method:

Sync gpx files by dropbox.
Use the (pc) gpx editor.
Show trackpoints display.
Right click column timestamps.
Select remove timestamps.
Save the gpx file. Done.
Locus Pro 3.59.0
 

Offline tapio

  • Expert
  • Master of Locus
  • ****
  • Posts: 861
  • Thanked: 176 times
    • View Profile
Re: [Tasker] Remove timestamps from GPX files
« Reply #9 on: January 10, 2022, 20:30:04 »
With this script I stay on Android and remove timestamps from all gpx files in a folder. Select dir, wait, done.
« Last Edit: January 10, 2022, 20:56:53 by tapio »
LM4 USER ID: 1AACAFF2A2
 

Offline 0709

  • Apprentice of Locus
  • **
  • Posts: 112
  • Thanked: 49 times
    • View Profile
    • Locus track navigation
  • Device: THL4000 CM12.1 (A5.1.1) MI A2 Lite (A9)
Re: [Tasker] Remove timestamps from GPX files
« Reply #10 on: January 11, 2022, 09:22:15 »
Quote
Tasker ?  Fine. Roger
I don't use Tasker anyway.
Therefore this alternative.
Multiple choice is nice, isn't it?
That is all. Roger?

Locus Pro 3.59.0
 
The following users thanked this post: tapio