Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- IFS=$'\n'
- mkdir unknown
- for i in $(ls -1 *.{m,M}{p,P}3)
- do
- filename=${i%[.][mM][pP][3]}
- id3v2 -l -C "$i"
- id3_artist=`id3v2 -l "$i" | grep -i TPE1 | cut -d ':' -f 2`
- id3_title=`id3v2 -l "$i" | grep -i TIT2 | cut -d ':' -f 2`
- id3_album=`id3v2 -l "$i" | grep -i TALB | cut -d ':' -f 2`
- id3_track=`id3v2 -l "$i" | grep -i TRCK | cut -d ':' -f 2`
- id3_year=`id3v2 -l "$i" | grep -i TYER | cut -d ':' -f 2`
- id3_lang=`id3v2 -l "$i" | grep -i TLEN | cut -d ':' -f 2`
- id3_artist=${id3_artist:1}
- id3_title=${id3_title:1}
- id3_album=${id3_album:1}
- id3_track=${id3_track:1}
- id3_year=${id3_year:1}
- id3_lang=${id3_lang:1}
- ffmpeg -i "$i" -acodec libvorbis -aq 6 "$filename.ogg"
- vorbiscomment -a -R \
- -t "ARTIST=$id3_artist" \
- -t "TITLE=$id3_title" \
- -t "ALBUM=$id3_album" \
- -t "TRACKNUMBER=$id3_track" \
- -t "DATE=$id3_year" \
- -t "LANGUAGE=$id3_lang" \
- -t "GENRE=" \
- -t "ALBUM_PIC=" \
- -t "YOUTUBE=" \
- "$filename.ogg"
- if [ -z $id3_artist ]; then
- mv "$filename.ogg" "unknown/$filename.ogg"
- else
- if [ -z $id3_album ]; then
- mkdir -p "$id3_artist/unknown"
- mv "$filename.ogg" "$id3_artist/unknown"
- else
- mkdir -p "$id3_artist/$id3_album"
- if [ -z $id3_title ]; then
- mv "$filename.ogg" "$id3_artist/$id3_album/X - $filename.ogg"
- else
- mv "$filename.ogg" "$id3_artist/$id3_album/$id3_track - $id3_title.ogg"
- fi
- fi
- fi
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement