Created
June 28, 2010 13:55
-
-
Save luisuribe/455867 to your computer and use it in GitHub Desktop.
Change id3v2 tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/dash | |
| # | |
| # TODO | |
| # - Fix code | |
| # - Port to phyton | |
| # Usage: ./script.sh -n | |
| # Variables | |
| #################################################################### | |
| encoder=/usr/bin/id3v2 | |
| tmp_file=.lista_$$ | |
| bitrate=160 | |
| number=0 | |
| #################################################################### | |
| # Funcion para capturar datos | |
| # Tomada del /usr/sbin/adduser del Slackware 10.0 | |
| #################################################################### | |
| function get_input ( ) { | |
| local output | |
| if [ "`echo $BASH_VERSION | cut -b1`" = "1" ]; then | |
| echo -n "${1} " >&2 # fudge for use with bash v1 | |
| read output | |
| else # this should work with any other /bin/sh | |
| read -ep "${1} " output | |
| fi | |
| echo $output | |
| } | |
| #################################################################### | |
| # Funcion principal | |
| #################################################################### | |
| ordenado="no"; | |
| while getopts ":mnopq:rs" Option | |
| do | |
| case $Option in | |
| n ) ordenado="yes" ; | |
| esac | |
| done | |
| for i in `ls *.mp3` | |
| do | |
| nombre="$(get_input "Nuevo nombre [ $i ]:")" | |
| if [ -z "$nombre" ]; then | |
| nombre="$i" | |
| else | |
| nombre="$nombre" | |
| fi | |
| opciones="-t \""$nombre"\"" | |
| number=$(($number+1)) | |
| if [ "$number" -lt "10" ]; then | |
| orden=0"$number" | |
| else | |
| orden="$number" | |
| fi | |
| tmp_input="$(get_input "Artista [ $artista ]:")" | |
| if [ -z "$tmp_input" ]; then | |
| if [ "$artista" != "" ]; then | |
| opciones=""$opciones" -a \""$artista"\"" | |
| fi | |
| else | |
| artista="$tmp_input" | |
| opciones=""$opciones" -a \""$artista"\"" | |
| fi | |
| tmp_input="$(get_input "Album [ $album ]:")" | |
| if [ -z "$tmp_input" ]; then | |
| if [ "$album" != "" ]; then | |
| opciones=""$opciones" -A \""$album"\"" | |
| fi | |
| else | |
| album="$tmp_input" | |
| opciones=""$opciones" -A \""$album"\"" | |
| fi | |
| tmp_input="$(get_input "Año [ $anio ]:")" | |
| if [ -z "$tmp_input" ]; then | |
| if [ "$anio" != "" ]; then | |
| opciones=""$opciones" -y '"$anio"'" | |
| fi | |
| else | |
| anio="$tmp_input" | |
| opciones=""$opciones" -y '"$anio"'" | |
| fi | |
| tmp_input="$(get_input "Genero [ $genero ]:")" | |
| if [ -z "$tmp_input" ]; then | |
| if [ "$genero" != "" ]; then | |
| opciones=""$opciones" -g '"$genero"'" | |
| fi | |
| else | |
| genero="$tmp_input" | |
| opciones=""$opciones" -g '"$genero"'" | |
| fi | |
| if [ $ordenado = "yes" ] ; then | |
| CMD=""$encoder" -D \""$i"\"" | |
| echo $CMD >> .lista_$$ | |
| CMD=""$encoder" -1 "$opciones" \""$i"\" -T "$orden"" | |
| echo $CMD >> .lista_$$ | |
| CMD=""$encoder" -2 "$opciones" \""$i"\" -T "$orden"" | |
| echo $CMD >> .lista_$$ | |
| CMD="mv \""$i"\" \""$orden" - "$artista" - "$nombre".mp3\"" | |
| echo $CMD >> .lista_$$ | |
| else | |
| CMD=""$encoder" -D \""$i"\"" | |
| echo $CMD >> .lista_$$ | |
| CMD=""$encoder" -1 "$opciones" \""$i"\"" | |
| echo $CMD >> .lista_$$ | |
| CMD=""$encoder" -2 "$opciones" \""$i"\"" | |
| echo $CMD >> .lista_$$ | |
| CMD="mv \""$i"\" \""$artista" - "$nombre".mp3\"" | |
| echo $CMD >> .lista_$$ | |
| fi; | |
| done | |
| sh .lista_$$ | |
| rm -f .lista_$$ | |
| #################################################################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment