2009/03/19

id3lib-rubyを使ってみる

gem install id3lib-rubyでインストール。以下ソース。

#!ruby -Ku

require "rubygems"
require "id3lib"

dir = 'C:\Music'
flist = []
flist = Dir.entries(dir)
flist.each do |f|
if f =~ /mp3/ then
tag = ID3Lib::Tag.new(dir + "\\" + f)
info = tag.artist + ":[" + tag.title + "]" + " from " + "\"" + tag.album + "\""
puts info
end
end


結果。

Jessica Cole:[Maker of Life] from "My Story"
Jessica Cole:[Psalms 134] from "My Story"
Jessica Cole:[Be Thou My Vision (Part 1)] from "My Story"
Jessica Cole:[My Story] from "My Story"
Jessica Cole:[Win the World] from "My Story"
Jessica Cole:[Get Back in the Race] from "My Story"
Jessica Cole:[I Give You My All] from "My Story"
Jessica Cole:[Psalms 40] from "My Story"
Jessica Cole:[He Came to Die] from "My Story"
Jessica Cole:[Be Thou My Vision Reprise] from "My Story"
Jessica Cole:[All Around the World] from "My Story"


書き換えもできるみたいなので、もう少し遊んでみたい。