#!/bin/sh
# Fetch all hiking routes maintained by Harzklub e.V.
id=2993062

DIR=`mktemp -d`
echo "Output will be available here: $DIR"
cd $DIR
rel2gpx -g -w $id 2> ${id}.err > ${id}.out
grep "Sub-Relation:" ${id}.err | sed 's/^[[:space:]]\+Sub-Relation:[[:space:]]*//' > subroutes
for id in `cat subroutes`; do
  rel2gpx  -g -w $id 2> ${id}.err > ${id}.out
done
