#!/bin/bash
#
#	Script to convert mp3 to ogg
#
# dependencies
#	bash
#   zenity
#	gst-launch
#   vorbisenc
#
# version 0.1 2012-01-15
#
# Ingemar Karlsson <ingemar@ingk.se>
# http://salixos.ingk.se
#
# Modified version of mp3toogg.sh found here https://www.linux.com/learn/tutorials/440846-extend-xfces-thunar-file-manager-with-custom-actions

#	English	#
############
strCONVERT="Converting"

case $LANG in
	#	Swedish	#
	sv*)
		strCONVERT="Konverterar"
	;;
esac

PERC=0
STEP=$((100/$#))

(for TRACK in "$@" ; do
	# allow filenames containing dots such as "an artist feat. some_other_artist"
	echo "# $strCONVERT $TRACK"
	OGGOUT=$(ls "$TRACK" |sed 's/\(.*\)\..*/\1/')
	gst-launch filesrc location="$1" ! decodebin ! audioconvert ! \ vorbisenc name=enc quality=0.7 ! oggmux ! filesink location="$OGGOUT.ogg" 
	let PERC=$PERC+$STEP
	echo $PERC; sleep 0.1
done) | zenity --progress --title "$strCONVERT..." --percentage=0  --auto-close
