En cette période de vacances, pour ceux d’entre nous désirant se faire une petite compilation musicale
pour la route, voici deux petits scripts bash pour convertir les fichiers flac et ogg en mp3 avec récupération
des principales métadonnées (artiste, titre etc.).
Code : Tout sélectionner
#!/bin/bash
# flac2mp3 - A script to convert flac files in mp3
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
if ! test -x /usr/bin/flac; then
echo "Please, install flac package."
exit 0
fi
if ! test -x /usr/bin/lame; then
echo "Please, install lame package."
exit 0
fi
case "$@" in
.*.[fF][lL][aA][cC]|*.[fF][lL][aA][cC])
for file in "$@"; do
for tag in artist album date genre title tracknumber tracktotal; do
eval $tag=\""$(metaflac --show-tag=$tag "$file" \
| sed s/.*=//g)"\"
done
flac -d -c "$file" | lame --vbr-new --preset standard \
--id3v2-only --id3v2-utf16 \
--tg "$genre" \
--ta "$artist" \
--tl "$album" \
--ty "$date" \
--tt "$title" \
--tn "$tracknumber/$tracktotal" \
- "${file/.[fF][lL][aA][cC]/.mp3}"
done
;;
*)
echo "Usage: flac2mp3 file.flac or *.flac"
;;
esac
exit 0
Code : Tout sélectionner
#!/bin/bash
# ogg2mp3 - A script to convert ogg files in mp3
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
#
if ! test -x /usr/bin/oggdec; then
echo "Please, install vorbis-tools package."
exit 0
fi
if ! test -x /usr/bin/lame; then
echo "Please, install lame package."
exit 0
fi
case "$@" in
.*.[oO][gG][gG]|*.[oO][gG][gG])
for file in "$@"; do
for tag in artist album date genre title tracknumber; do
eval $tag=\""$(vorbiscomment "$file" | grep $tag \
| sed s/.*=//g)"\"
done
oggdec -o /dev/stdout "$file" | lame --vbr-new --preset standard \
--id3v2-only --id3v2-utf16 \
--tg "$genre" \
--ta "$artist" \
--tl "$album" \
--ty "$date" \
--tt "$title" \
--tn "$tracknumber" \
- "${file/.[oO][gG][gG]/.mp3}"
done
;;
*)
echo "Usage: ogg2mp3 file.ogg or *.ogg"
;;
esac
exit 0
une action personnalisée sur l’un et l’autre script pour effectuer une conversion par lot via un clic droit…