diff options
Diffstat (limited to 'tracks/rename.sh')
-rw-r--r-- | tracks/rename.sh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tracks/rename.sh b/tracks/rename.sh new file mode 100644 index 0000000..e1504a9 --- /dev/null +++ b/tracks/rename.sh @@ -0,0 +1,15 @@ +#! /bin/bash + +mkdir -p GPX/Archive + +for name in $(ls Route*.gpx Track*.gpx 2>/dev/null); do + new_name=$(cat "$name" | grep -oP "(?<=<name>).*?(?=</name>)" | head -n 1 | sed -e 's/[^0-9a-zA-Z]\+/_/g').gpx + if [[ "$name" =~ ^Route ]]; then + new_name="GPX/$new_name" + else + new_name="GPX/Archive/$new_name" + fi + echo "Renaming: $name to $new_name" + mv "$name" "$new_name" +done +[ -f Waypoints.gpx ] && mv Waypoints.gpx GPX/ |