Symlink UTF-7 directory name into an UTF-8 version
#!/usr/bin/env ruby | |
# Maildir folder: create an UTF-8 symlink to original UTF-7 maildir. | |
# For example, it will create a symlink named '所有邮件' to a directory | |
# named '&YkBnCZCuTvY-' | |
utf7_dirs = Dir.entries(Dir.pwd).select do |dir| | |
dir.start_with?("&") | |
end | |
utf7_dirs.each do |dir| | |
utf7 = dir.gsub('&', '+').gsub(',', '/') | |
utf8 = (`echo '#{utf7}' | iconv -f UTF-7 -t UTF-8`).chomp | |
unless File.exists?(utf8) | |
File.symlink(dir, utf8) | |
puts "#{dir} => #{utf8}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment