Ok. C'est fait, les arborescences sont maitenant prises en charges.
Donc. On selectionne les fichiers et/ou repertoires dans Nautilus.
Ensuite on clique droit / Scripts / Convertir en mp3
Une fenetre de selection de repertoire s'ouvre alors. On ne peut selectionner qu'un seul repertoire ici. Celui ou les fichiers convertis seront mis.
Ensuite une fenetre de selection du debit s'ouvre.
Tout se passe ensuite en tache de fond.
Un fichier de log est cree: ~/mp3-convert.log (a consulter pour voir les eventuelles erreurs rencontrees)
ogg, flac, wav, mp3, ra, aac, etc. tout format reconnu par gstreamer peuvent etre convertis!
Convertir en autre chose qu'en mp3, changer les options de codage etc.. ne demande que des changements triviaux au script. A vous de l'adapter a vos besoins.
Se6.
A mettre dans un fichier ~/.gnome2/nautilus-scripts/Convertir en mp3
et a rendre executable.
#!/bin/bash
#
# dependancies:
# zenity
# gstreamer0.10-plugins-ugly
# gstreamer-tools
#
# Usage: To use in Nautilus
# You select files and directorie in Nautilus, then you right click, script/Convert to mp3...
# A first dialog will ask you where to put the converted files
# A second one will let you select the bit rate
# Then everything will happen in the background, no other info will be printed...
# A log file ~/mp3-convert.log will be created.
#
LOGFILE=~/mp3-convert.log
echo "" >$LOGFILE
exec 1>>$LOGFILE
exec 2>>$LOGFILE
LOC=$(zenity --file-selection --directory --title="Directory to receive the converted audio") || exit
RATE=$(zenity --list --radiolist \
--height=400 \
--text="bitrate in kb/s" --title="Select mp3 bit rate" \
--column="Select" --column="Bit rate" \
FALSE 32 FALSE 48 FALSE 56 FALSE 64 FALSE 80 FALSE 96 FALSE 112 TRUE 128 FALSE 160 FALSE 192 FALSE 224 FALSE 256 FALSE 320 \
) || exit
IFS=$'\n'
for SELECTED in $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS
do
if [ -f "$SELECTED" ]
then
TARGET="$(basename $SELECTED)"
TARGET=${TARGET%.*}.mp3
if [ -e "$LOC/$TARGET" ]
then
echo -e "\n# Warning: $LOC/$TARGET already exist, did not overwrite it."
else
echo -e "\n#Processing $SELECTED -> $LOC/$TARGET"
gst-launch filesrc location="$SELECTED" ! decodebin ! audioconvert ! lame bitrate=$RATE ! filesink location="$LOC/$TARGET"
fi
elif [ -d "$SELECTED" ]
then
TARGET_DIR="$LOC/${SELECTED##*/}"
if [ ! -d "$TARGET_DIR" ]
then
mkdir -p "$TARGET_DIR"
fi
for FILENAME in $(find "$SELECTED" -type f -printf "%p\n")
do
THEDIR=${FILENAME%/*}
THEDIR=${THEDIR:${#SELECTED}}
THEDIR="$TARGET_DIR$THEDIR"
if [ ! -d "$THEDIR" ]
then
mkdir -p "$THEDIR"
fi
TARGET="$(basename $FILENAME)"
TARGET=${TARGET%.*}.mp3
if [ -e "$THEDIR/$TARGET" ]
then
echo -e "\n#Warning: $THEDIR/$TARGET already exist, did not overwrite it."
else
echo -e "\n#Processing $FILENAME -> $THEDIR/$TARGET"
gst-launch filesrc location="$FILENAME" ! decodebin ! audioconvert ! lame bitrate=$RATE ! filesink location="$THEDIR/$TARGET"
if [ ! -s "$THEDIR/$TARGET" ]
then
echo "# It probably was not audio, copying instead."
rm "$THEDIR/$TARGET"
cp -a -- "$FILENAME" "$THEDIR/$(basename $FILENAME)"
fi
fi
done
fi
done