-
Notifications
You must be signed in to change notification settings - Fork 0
/
gps-cvt.sh
55 lines (55 loc) · 1.98 KB
/
gps-cvt.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
54
55
#!/usr/bin/bash
#------------------------------------------------------------------------------#
# Programmed By Liz #
#------------------------------------------------------------------------------#
# GPS file converter for caja
# uses garmin-cvt.sh & related programs
# moves conversion to extension sub-directory
#
# did this mainly for MapSource MPS -> GPX
#
# 2024-04-02 fixed move glitch, was moving _Notes.txt
# 2024-04-02 removed notify-send, now in garmin-cvt.sh
#---------------------------------------------------------------- initialization
hdg="GPS File Convert"
cat="$HOME/.icons/EMOJI Fav/Cat.png"
err="$HOME/.icons/EMOJI Fav/Skull And Crossbones.png"
#---------------------------------------------------------------------- function
function fx_gps-cvt () # convert gps file
{
dir=${1%/*}
fil=${1##*/}
# notify-send -i "$cat" "Converting" "$fil"
garmin-cvt.sh "$1"
}
#------------------------------------------------------------------ main program
if [[ $CAJA_SCRIPT_SELECTED_FILE_PATHS == "" ]]
then # single file
if [[ $1 == "" ]]
then
notify-send -i "$err" "ERROR!" "nothing to process"
exit 1
fi
notify-send -i "$cat" "$hdg" "single file"
src="$1"
fx_gps-cvt "$1"
else # scan files
while read src
do
if [[ "$src" != "" ]] # ignore empty lines
then
fx_gps-cvt "$src"
fi
done <<< $CAJA_SCRIPT_SELECTED_FILE_PATHS
for ext in gpx txt wpt # move conversions
do
find "$dir" -maxdepth 1 -type f -name "*.$ext" \! -name "_*" |
while read src
do
mkdir -p "$dir/$ext"
mv "$src" "$dir/$ext"
done
done
notify-send -i "$cat" "Finished" "conversions moved to extension directory"
fi
#-------------------------------------------------------------------------------