Created
February 9, 2012 17:07
-
-
Save sorah/1781204 to your computer and use it in GitHub Desktop.
for banshee... (public domain, own your risk)
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
# Converts UTF-8-MAC filenames in "iTunes Music Library.xml" to UTF-8 | |
# | |
# Usage: ruby itunes_nfc.rb iTunes\ Music\ Library.xml > iTunes\ Music\ Library.xml | |
# License: public domain | |
# | |
# own your risk. | |
require'uri' | |
xml = ARGF.readlines | |
r = xml.map do |line| | |
next line unless /(\t*)<key>Location<\/key><string>(.*?)<\/string>(\r?\n)/ =~ line | |
t, oufn, ret = $1, $2, $3 | |
ofn = URI.unescape(oufn) | |
cfn = ofn.force_encoding("UTF-8-MAC").encode("UTF-8") | |
cufn = URI.escape(cfn).gsub(/&%23/,'&#') | |
"#{t}<key>Location</key><string>#{cufn}</string>#{ret}" | |
end | |
puts r.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment