cp Gipfelbuch_huts.kml Gipfelbuch_huts_BU.kml
# remove peaks, pass and situation warnings
perl -i -pe "s|\<Placemark id\=.pea.*?\<\/Placemark\>||g" Gipfelbuch_huts.kml
perl -i -pe "s|\<Placemark id\=.pas.*?\<\/Placemark\>||g" Gipfelbuch_huts.kml
perl -i -pe "s|\<Placemark id\=.situ.*?\<\/Placemark\>||g" Gipfelbuch_huts.kml
# convert in gpx, but does not keep the names ...
gpsbabel -i kml -f Gipfelbuch_huts.kml -o gpx -F Gipfelbuch_huts.gpx
# add carriage return to work per line
perl -i -pe "s|<Placemark|\r\n<Placemark|g" Gipfelbuch_huts.kml
# get alone the name of the huts
perl -pe "s|.*(Hütte.*?)<.*|\1|p" Gipfelbuch_huts.kml | grep Hütte > kmlnames.txt
# remove soe shitty characters
perl -i -pe "s|\'| |g" kmlnames.txt
perl -i -pe "s|\„| |g" kmlnames.txt
# prepare a bash file to replace name in gpx by the real name
nrow=$(cat kmlnames.txt | wc -l)
j=1
echo "echo Script running" > Change_names.sh
for i in $( eval echo {001..$nrow} )
do
in="WPT$i"
out=$(sed "${j}q;d" kmlnames.txt)
echo "perl -i -pe 's|${in}|${out}|g' Gipfelbuch_huts.gpx" >> Change_names.sh
((j++))
done
# run it
./Change_names.sh
# del what not needed
rm kmlnames.txt Change_names.sh