sábado, 27 de diciembre de 2008

Convert ogg to mp3 respecting the heads

Este script te convierte archivos ogg en archivos mp3 manteniendo las cabeceras, es decir la metainformación de los archivos originales, como título, autor, etc. Es muy sencillo de usar:

ogg2mp3 files...

Te crea, por cada archivo .ogg que se le introduzca como parámetro, otro con el mismo nombre en mp3 en el directorio actual.



#!/bin/bash
###############################################################################
### Script to calculate the estimated time to finish a process. ###
### ###
### LICENSE: ###
### estimatetime 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 3 of the License, or ###
### (at your option) any later version. ###
### ###
### estimatetime 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 InTiMe. If not, see . ###
### ###
### AUTHORS: ###
### José Manuel Gómez Soriano ###
###############################################################################
usage()
{
echo `gettext "Usage"`":" `basename $0` "[files...]"
echo " " `basename $0` "-h"
echo `gettext "Convert serveral ogg files to mp3 respecting the sound file metadata."`
echo
echo -e " -h\t\t\t"`gettext "Show this help."`
}

while getopts "h" option
do
case "$option" in
h) usage; exit 0;;
[?]) usage; exit 1;;
esac
done
shift $(($OPTIND-1))

if [[ $# -lt 1 ]]
then
echo "One or more ogg files are necessary." > /etc/stderr
usage
exit 1
fi

for f in "$@"; do
echo $f
#f=$1
oggdec "$f" &&
filename=`echo $f | sed 's/\.ogg$//'` &&
info=`ogginfo "$f"` &&
title=`echo -e "$info" | grep 'TITLE' | sed 's/^\tTITLE=//'` &&
artist=`echo -e "$info" | grep 'ARTIST' | sed 's/^\tARTIST=//'` &&
album=`echo -e "$info" | grep 'ALBUM' | sed 's/^\tALBUM=//'` &&
year=`echo -e "$info" | grep 'DATE' | sed 's/^\tDATE=//'` &&
comment=`echo -e "$info" | grep 'COMMENT' | sed 's/^\tCOMMENT=//'` &&
track=`echo -e "$info" | grep 'TRACKNUMBER' | sed 's/^\tTRACKNUMBER=//'` &&
genre=`echo -e "$info" | grep 'GENRE' | sed 's/^\tGENRE=//' | awk -F '/' -F ' ' '{print $1}'` &&
if [[ -z $genre ]];
then
lame -h --tt "$title" --ta "$artist" --tl "$album" --ty "$year" --tc "$comment" --tn "$track" "$filename.wav" "$filename.mp3"
else
lame -h --tt "$title" --ta "$artist" --tl "$album" --ty "$year" --tc "$comment" --tn "$track" --tg "$genre" "$filename.wav" "$filename.mp3"
fi
rm "$filename.wav"
done


No hay comentarios: