Created
December 22, 2012 20:18
-
-
Save devpg/4360864 to your computer and use it in GitHub Desktop.
Exports the iTunes music library of the current user by coping *.mp3 files into folder based on the genre
This file contains 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 | |
# Rewrite IFS default seperator | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
itunesFolder="/Users/$USER/Music/iTunes/iTunes Media/Music" | |
for file in $(find "$itunesFolder" -name '*.mp3'); do | |
genre=$(id3v2 -l "$file" | sed -n '/^TCON/s/^.*: //p' | sed 's/ (.*//') | |
if [ -n "$genre" ] && [ \! -d "$1/$genre" ]; then | |
mkdir "$1/$genre" | |
fi | |
# Missing "genre" will copy the file to the root output folder | |
cp "$file" "$1/$genre" | |
echo "$genre ==> $(basename $file)" | |
done | |
# Set IFS default seperator | |
IFS=$SAVEIFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment