Skip to content

Instantly share code, notes, and snippets.

@yhara
Created May 28, 2009 09:16
Show Gist options
  • Save yhara/119193 to your computer and use it in GitHub Desktop.
Save yhara/119193 to your computer and use it in GitHub Desktop.
require 'kconv'
def title_of(path)
case path
when /\d\d-(.*)\.mp3/, /\d\d_(.*)\.mp3/, /\d\d(.*)\.mp3/
$1.tosjis
else
raise path
end
end
def tag!(files, is_dry, album=nil)
files.each_with_index do |path, i|
extra_option = "--album '#{album}'" if album
#"--artist 'capsule' --album 'Fruits Clipper'"
cmd = "id3v2 --song '#{title_of(path)}' --track #{i+1} #{extra_option} '#{path}'"
puts cmd
system cmd unless is_dry
end
end
if ARGV.size==0
puts "usage: #$0 dir"
puts "options: -d : dry-run"
else
files = Dir["#{ARGV[0]}/*.mp3"]
tag!(files, ARGV[1] == "-d", File.basename(ARGV[0]))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment