Skip to content

Instantly share code, notes, and snippets.

@raa0121
Created December 24, 2011 00:45
Show Gist options
  • Save raa0121/1515807 to your computer and use it in GitHub Desktop.
Save raa0121/1515807 to your computer and use it in GitHub Desktop.
html実体参照なファイル名をリネームするスプリクト for win
#!/use/bin/ruby -Ks
#codeing:sjis
require 'rubygems'
require 'htmlentities'
def printDirs(dir)
Dir::entries(dir).sort.each do |child|
path = dir + "/" + child;
if child == "." or child == ".."
# do nothing
elsif File::ftype(path) == "directory"
printDirs(path, &Proc.new{|it| yield(it)})
else
yield(path)
end
end
end
printDirs(".") do |it|
it2 = File::basename(it)
puts it2+"\n"
it3 = HTMLEntities.new.decode(it2).encode("Shift_JIS")
if it2 != "rename_file.rb" and it2!=it3
File.rename(it2,it3)
end
puts it3+"\n"
end
print "Push anykey:"
gets.chop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment