Created
July 15, 2011 04:22
-
-
Save fzero/1084055 to your computer and use it in GitHub Desktop.
A quick automatic tagger for MP3 (uses eyeD3 - http://eyed3.nicfit.net)
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/bash | |
# This expects files ordered like: | |
# Artist/Album/01 Track Title.mp3 | |
# | |
# You should provide the dir containing the Artist dirs at the command line. | |
START="$1" | |
if [ "$START" == "" ]; then | |
echo "You must tell me where to start." | |
exit 1 | |
fi | |
cd "$START" | |
for ARTIST in *; do | |
if [ "$ARTIST" == "VA" ]; then | |
# Avoids albums by Various Artists | |
continue | |
fi | |
cd "$ARTIST" | |
for ALBUM in *; do | |
cd "$ALBUM" | |
if [ "$(ls *.mp3)" == "" ]; then | |
# Skips empty dirs/non-mp3 files (for now) | |
cd .. | |
continue | |
fi | |
for FILE in *.mp3; do | |
TRACK=$(echo "$FILE" | egrep -o ^[0-9]{2}) | |
SONG=$(echo "$FILE" | sed s/^[0-9][0-9]\ // | sed s/\.mp3$//) | |
# Workaround for eyeD3 bug with UTF8 chars | |
eyeD3 --to-v2.4 "$FILE" | |
# DO IT! | |
eyeD3 --to-v2.4 --set-encoding=utf8 \ | |
--artist "$ARTIST" \ | |
--album "$ALBUM" \ | |
--title "$SONG" \ | |
--track $TRACK "$FILE" || exit 1 | |
done | |
cd .. | |
done | |
cd .. | |
done |
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/bash | |
# Same as masstagger, but for albums by Various Artists | |
# Differences: uses one less directory level and detects artists/titles differently. | |
# | |
# Expects files like: | |
# VA/Album/01 Artist Name - Track Title.mp3 | |
# | |
# You should provide the "VA" dir at the command line. | |
START="$1" | |
if [ "$START" == "" ]; then | |
echo "You must tell me where to start." | |
exit 1 | |
fi | |
cd "$START" | |
for ALBUM in *; do | |
cd "$ALBUM" | |
if [ "$(ls *.mp3)" == "" ]; then | |
# Skips empty dirs/non-mp3 files (for now) | |
cd .. | |
continue | |
fi | |
for FILE in *.mp3; do | |
TRACK=$(echo "$FILE" | egrep -o ^[0-9]{2}) | |
ARTIST=$(echo "$FILE" | sed s/^[0-9][0-9]\ // | sed s/\.mp3$// | sed s/\ \-.*//) | |
SONG=$(echo "$FILE" | sed s/^[0-9][0-9]\ // | sed s/\.mp3$// | sed s/"$ARTIST - "//) | |
# Workaround for eyeD3 bug with UTF8 chars | |
eyeD3 --to-v2.4 "$FILE" | |
# DO IT! | |
eyeD3 --to-v2.4 --set-encoding=utf8 \ | |
--artist "$ARTIST" \ | |
--album "$ALBUM" \ | |
--title "$SONG" \ | |
--track $TRACK "$FILE" || exit 1 | |
done | |
cd .. | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah, it's full of bad practices, but I hacked this in less than one hour and it worked for me and my files. Feel free do adapt for your own messy library. :-)