Created
May 28, 2009 09:16
-
-
Save yhara/119193 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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