#!/usr/bin/bash
#------------------------------------------------------------------------------#
#                            Programmed By Liz                                 #
#------------------------------------------------------------------------------#
# GPS file converter for caja
# uses delorme-txt.sh & related programs
# moves conversion to extension WinXP/DeLorme
#---------------------------------------------------------------- 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"
   delorme-txt.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
   notify-send -i "$cat" "Finished" "conversions moved to WinXP/DeLorme/gpx"
fi
#-------------------------------------------------------------------------------