Skip to content

Instantly share code, notes, and snippets.

@lenage
Created August 28, 2012 17:45
Show Gist options
  • Save lenage/3501315 to your computer and use it in GitHub Desktop.
Save lenage/3501315 to your computer and use it in GitHub Desktop.
Get mp3info from a fold use ruby
require 'mp3info'
dir = File.expand_path("../", __FILE__)
Dir["#{dir}/*"].each do |sub_dir|
if File.directory?(sub_dir)
Dir.entries(sub_dir).each do |file|
if file =~ /mp3/
title = file.split("-").last.sub(/.mp3/, "")
artist = file.scan(/_(\w+)/).flatten.first
Mp3Info.open( sub_dir + "/" + file ) do |mp3|
mp3.tag.title = title
mp3.tag.artist = artist
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment