Created
June 3, 2013 17:39
-
-
Save krtx/5699843 to your computer and use it in GitHub Desktop.
mp3のタグを書き換えるスクリプト ruby 1.9.2
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 'mp3info' | |
dir = '/my/music/library/' | |
Dir::glob(dir + '*.mp3').each {|f| | |
Mp3Info.open(f) do |mp3| | |
t = mp3.tag.title | |
title = t.slice(t.rindex('/') + 2, t.length) | |
artist = t.slice(0, t.rindex('/') - 1) | |
if title.index(' - ') | |
title = title.slice(0, title.index(' - ')) | |
end | |
puts "#{artist} // #{title}" | |
title = title.encode('us-ascii', 'utf-8') | |
artist = artist.encode('us-ascii', 'utf-8') | |
aartist = "Various Artists".encode('us-ascii', 'utf-8') | |
mp3.tag.title = title | |
mp3.tag.artist = artist | |
mp3.tag2.TP2 = aartist | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment