Linux-批量转换-GBK-to-UTF8

<pre class="lang:ruby decode:true " >
#!/usr/bin/ruby
require 'find'
require 'fileutils'

Find.find('./yun3.2').each do |i|
    dir = i.gsub('yun3.2', 'yun')
    if File.directory?(i)
      `mkdir -p #{dir}`
    elsif File.basename(i)
      filename = File.basename(i)
      if filename.include?('.htm')  || filename.include?('.js') || filename.include?('.css')
        file_type = `file #{i}`
        if file_type.include?('UTF-8')
          FileUtils.cp_r(i, dir)
        else
          puts "iconv -f GB2312 -t UTF-8 #{i} -o #{dir}"
        end
      else
          FileUtils.cp_r(i, dir)
      end
    end
end


#删除bom
grep -r -I -l $'^\xEF\xBB\xBF' ./

find . -type f   -exec  sed -i 's/\xEF\xBB\xBF//' {} \;
#ruby脚本 批量 递归