Started by Tapio, November 14, 2021, 18:09:56
0 Members and 1 Guest are viewing this topic.
sed -i -z 's;[\s\t]*<time>[^<]*</time>[^<]*;;g' '%file'</Str>
Quote from: tapio on November 14, 2021, 18:09:56With 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
Quote from: tapio on November 15, 2021, 10:30:50Quote from: Andrew Heard on November 14, 2021, 22:01:57I see the main processing is done via the lineCode Select Expandsed -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
Quote from: Andrew Heard on November 14, 2021, 22:01:57I see the main processing is done via the lineCode Select Expandsed -i -z 's;[\s\t]*<time>[^<]*</time>[^<]*;;g'
sed -i -z 's;[\s\t]*<time>[^<]*</time>[^<]*;;g'
Quote from: tapio on January 07, 2022, 11:35:23Ugh, 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
QuoteTasker ? Fine. Roger