Created
September 27, 2008 14:11
-
-
Save sunfmin/13331 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 'rubygems' | |
require 'mp3info' | |
from_folder = "/Users/sunfmin/Music/Music2" | |
mv_to_folder = "/Users/sunfmin/Music/Cleaned" | |
def fix(f) | |
Mp3Info.open(f, :encoding => "utf-8") do |mp3info| | |
print Iconv.iconv('utf-8', 'gbk', mp3info.tag.album) | |
print " - " | |
print Iconv.iconv('utf-8', 'gbk', mp3info.tag.artist) | |
print " - " | |
puts Iconv.iconv('utf-8', 'gbk', mp3info.tag.title) | |
mp3info.tag.album = Iconv.iconv('utf-8', 'gbk', mp3info.tag.album).to_s | |
mp3info.tag.artist = Iconv.iconv('utf-8', 'gbk', mp3info.tag.artist).to_s | |
mp3info.tag.title = Iconv.iconv('utf-8', 'gbk', mp3info.tag.title).to_s | |
end | |
system("mv \"#{f}\" #{mv_to_folder}") | |
end | |
Dir.chdir(from_folder) | |
Dir.glob("*/**").each do |f| | |
begin | |
fix(f) | |
rescue Exception => e | |
puts e.inspect, f | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment