Dir.glob("**/*") do |v| lines = [] changed = false next if File.directory? v IO.foreach(v) {|line| if line =~ /mutoh(at|@)highway.ne.jp/ lines << line.gsub(/mutoh( at |@)highway.ne.jp/, "mutomasa at gmail.com") changed = true else lines << line end } if changed out = open(v, "w") lines.each {|l| out.write l } out.close end end