#! /bin/bash
#
# Ingemar Karlsson <ingemar@ingk.se>
# http://salixos.ingk.se
#
# version 0.1 2011-12-28
#
# What do we want to do
case $1 in
	"c_p" )
		strCMD="cp"
	;;
	"m_v" )
		strCMD="mv"
	;;
esac

#	English	#
############
strTITLE_DIR="Select a directory"
strTITLE_CONFLICT="Conflict While Copying"
strFILE="File"
strTEXT_EXISTS="already exists. Would you like to replace it?"
strFINISH="Finished Copying Files."

case $LANG in
	#	Swedish	#
	sv* )
		strTITLE_DIR="Välj en katalog"
		strTITLE_CONFLICT="Konflikt vid koppiering"
		strFILE="Filen"
		strTEXT_EXISTS="finns redan. Vill du ersätta den?"
		strFINISH="Koppiering av filer klart."
esac

location=`zenity --file-selection --directory --title="$strTITLE_DIR"`
# If cancel is selected abort
case "$?" in
	1 )
		exit 1
		;;
esac

for arg
do
if [ "$arg" != "c_p" ] && [ "$arg" != "m_v" ]; then
	if [ -e "$location"/"$arg" ];then
		zenity --question --title="$strTITLE_CONFLICT" --text="$strFILE ""$location"/"$arg"" $strTEXT_EXISTS"
		case "$?" in
			1  )  
				exit 1 
				;;
			0  )  
				"$strCMD" "$arg" "$location"
				;;
		esac
	else
		"$strCMD" "$arg" "$location"
	fi
fi
done
