If you listen to a lot of podcasts on your mp3 player, you likely are annoyed by the fact that every podcast uses different tags for genres, artists, and more – or leaves them blank. You are constantly jumping around from artist to artist or genre to genre to find all your intended listening.

Side Note: This article was written in 2008 so some of the references may be out-of-date.

It can be a real pain.

The little ruby script will rewrite the ID3 tags on all the mp3 files in a selected directory – in this case ‘C:/Podcasts/’ – and change those id3 tags to something consistent so all the files are grouped together.

In this case, the script–

  • Sets genre to 'Podcasts'
  • Sets album to 'Podcast Album'
  • Sets artist to 'Podcast Artists'
  • Sets the title to a combination of the old album and title

Run this script after downloading your podcasts and before loading your player.

Also, some podcast receiver allow you to run a script automatically once downloads are complete.

#!/usr/bin/ruby -w
require 'id3lib'

pathOut = 'C:/Podcasts/'

#----------------------------------------------------------------------
# Pass 2 - fix id3 tags next
#----------------------------------------------------------------------

theFileList = []; 
Dir[pathOut + '*.mp3'].each do |fnn| 
  theFileList << fnn.downcase; 
end;

#----------------------------------------------------------------------
# Pass 1 - fix id3 tags
#----------------------------------------------------------------------

itrack = 0;
theFileList.each do |file_name| 

if file_name =~ /\.mp3$/ then
   itrack = itrack + 1
   puts
   puts "Processing #{itrack} - #{file_name}"
    
   file_path = file_name
   tag = ID3Lib::Tag.new(file_path)
   parts = file_name.split(/ \- /)
       
   if tag.album != 'Podcast Album' then
       if tag.album == nil then tag.album = 'null'; end;
       if tag.album.length < 1 then tag.album = '?'; end;
       if tag.title == nil then tag.title = 'null'; end;
       if tag.title.length < 1 then tag.title = '?'; end;
       mytitle = tag.album + ' - ' + tag.title;
       tag.title = mytitle;
       tag.album = 'Podcast Album'
       tag.genre = 'Podcasts'
       tag.artist = 'Podcast Artists'
       tag.year = 2008
   end;
       
   tag.track = itrack;
   tag.update!
    
   puts "Artist: #{tag.artist}"
   puts "Title: #{tag.title}"
   puts "Genre: #{tag.genre}"
    
end

end;

#----------------------------------------------------------------------
puts 'press return to continue...'
gets 

Installing id3lib

If you use RubyGems, run the following and select the newest version marked “ruby” –

gem install id3lib- ruby

“Enjoy…”