-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunpagpx.sh
executable file
·54 lines (53 loc) · 1.97 KB
/
unpagpx.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
# Copyright (C) 2013 Malte Kuhn <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# On Debian systems, you can find the full text of the license in
# /usr/share/common-licenses/GPL-3
if ([ "$2" == "" ] || [ "$1" == "" ] || [ ! -d $2 ] || [ ! -d $1 ]); then
echo "usage: $0 <sourcefolder> <destinationfolder>"
else
unpagpxTMP=`mktemp -d --suffix=unpagpx`
for savee in `ls $1*.gpx`; do
#echo - $savee :
saveeTYPE=`file -bzi $savee`
#echo $saveeTYPE
if [[ $saveeTYPE == "application/x-tar"*"compressed-encoding=application/x-gzip"* ]]; then
tar -C "$unpagpxTMP" -xzf "$savee"
:
elif [[ $saveeTYPE == *"compressed-encoding=application/x-gzip"* ]]; then
gzip -d < "$savee" > "$unpagpxTMP/decompressed-gz"
:
elif [[ $saveeTYPE == "application/x-tar"*"compressed-encoding=application/x-bzip2"* ]]; then
tar -C "$unpagpxTMP" -xjf "$savee"
:
elif [[ $saveeTYPE == *"compressed-encoding=application/x-bzip2"* ]]; then
bzip2 -d < "$savee" > "$unpagpxTMP/decompressed-bz2"
:
elif [[ $saveeTYPE == "application/x-tar"* ]]; then
tar -C "$unpagpxTMP" -xf "$savee"
:
elif [[ $saveeTYPE == *"compressed-encoding=application/zip"* ]]; then
unzip -q "$savee" -d "$unpagpxTMP"
:
elif ([[ $saveeTYPE == "application/xml"* ]] || [[ $saveeTYPE == "text/plain"* ]]); then
cp "$savee" "$unpagpxTMP/"
:
else
# UNKNOWN CONTAINER ignore
echo -n "$savee :"
echo $saveeTYPE
fi
bsname=`basename $savee .gpx`
counter=`mktemp --suffix=unpagpx`
echo 0 > $counter
find $unpagpxTMP -type f -exec ./checkncopy.sh {} $bsname $2 $counter \;
rm $counter
rm -r $unpagpxTMP/*
done
rm -rf $unpagpxTMP
fi