Skip to content

Instantly share code, notes, and snippets.

@dzhulk
Created October 4, 2011 11:50
Show Gist options
  • Select an option

  • Save dzhulk/1261446 to your computer and use it in GitHub Desktop.

Select an option

Save dzhulk/1261446 to your computer and use it in GitHub Desktop.
add encoding line
#!/usr/bin/env ruby
require "find"
def file_list(dir, parent_dir=nil)
list = []
Find.find("./#{dir}").map do |file|
unless File.directory? file
list << file
end
end
list
end
def operate(dir)
content = "# encoding: UTF-8\n"
file_list(dir).each do |file|
content << File.read(file)
File.open(file, "w") do |f|
f.write content
end
content = "# encoding: UTF-8\n"
end
end
operate(ARGV[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment