Renaming MP3 files based on ID3 tag information
Here is a neat little trick that I often find useful for renaming mp3 files with wrong names and correct tag titles. Just run this ruby script in the directory where you have stored your songs and it will read the tag title and rename the current file using it.
1: require "rubygems"
2: require "id3lib"
3: require "fileutils"
4:
5: files = `dir /s /b *.mp3`
6:
7: files.split("\n").each do |file|
8: dir = File.dirname(file)
9: tag = ID3Lib::Tag.new(file)
10: new_name = tag.title.gsub("00",'') if tag.title
11: FileUtils.move(file, File.join(dir, new_name + ".mp3")) if new_name and !new_name.empty? rescue nil
12: end
This script requires id3lib gem for ruby which can be installed simply by running the command:
gem install id3lib-ruby
One thing to notice in the script is that currently it works only on windows, but only with a little modification it can be made to work on other OSes as well (The only change I guess will be in the 5th line).
Here is the pastie link for this code.



[...] March 9, 2008 · No Comments I wanted to blog about this feature from so long (as it got released with Winamp 5.5 a long way back), but I couldn’t find enough time to do this.This weekend however, I had decided to use this feature heavily to tag almost all of my mp3s and hence I decided to blog about it too.What I’m talking about ? Auto-tagging in Winamp 5.5It’s a new feature introduced in Winamp 5.5 that tags your mp3 files using the Gracenote’s CDDB server. It doesn’t relies on any kind of meta-data present in file, neither it does uses the file name for this purpose. I suspect it sends some kind og hash (that I’ll have to hack around …).But what stands out is that Winamp was even able to tag a file name “dsfdsferfermvmev.mp3″ correctly. Using this feature you can tag and categorize unused songs in your mp3 archieve.How to find this feature in Winamp:There are two ways to use this feature:1. Double click on the scrolling title(or press Alt-3) to open file info dialog, in bottom right you’ll see Auto-tag button. 2. Create a playlist and select files and then right click on them, select send-to and select Auto-tag. A word of caution:Nothing is perfect ! so is this. Please keep an eye on the results of the auto-tagging, if you suspect anything wrong don’t apply the tag at all.Now what to do when your files have been tagged, but still their names are like r3rff34f.mp3, well you can use any software available in the market that can rename files based on their tag information or you can use the following ruby-script to rename them.Click here [...]
Winamp: Auto tag feature « {S.A.Z.W.Q.A}
March 9, 2008
[...] Click here [...]
Winamp: Auto tag feature « {S.A.Z.W.Q.A}
March 9, 2008
I’ve written a program in Java that is very small (300kb) and does all the work!
Check it out:
http://rapidshare.com/files/139661744/Mp3Renamer.jar
Note it’s still beta version.
Viktor Fonić
August 24, 2008
u shall replace
files = `dir /s /b *.mp3`
with Dir["*.mp3"], this will work on all platforms
Anonymous
March 26, 2009