Posts tagged ‘script groovy’

Getting ID3 information from MP3s

I was recently trying to index my music collection. The way you get track, artist, album and genre information from an MP3 is by reading ID3 encoded directly in the file.

Being a good citizen I began searching for an open source library that will allow me to read these tags and index file properly. That’s when I found the not so cryptically named Java ID3 Tag library.

Of course using it couldn’t be simpler.

def mp3file = new MP3File(mp3name)
def tag = mp3file.getID3v1Tag();

if (tag) {
println “${track.title} by ${track.artist} (album: ${tack.album})”
} else {
println “This song is not ID3 tagged”
}

Quite simple.