Skip to content

Instantly share code, notes, and snippets.

@TakashiNakagawa
Created January 29, 2013 00:24
Show Gist options
  • Save TakashiNakagawa/4660572 to your computer and use it in GitHub Desktop.
Save TakashiNakagawa/4660572 to your computer and use it in GitHub Desktop.
# coding: utf-8
require "fileutils"
require 'find'
count = 0
Find.find('./check_xml'){|f|
if File.basename(f) == ".DS_Store"
next
end
unless File::ftype(f) == "file"
next
end
#setting_templateの内容をコピー
array = Array.new
File::open("./setting_template.xml"){ |file|
file.each{ | line |
array.push(line)
}
}
#出力する文字列
output = ""
new_name = "setting_template.xml_" + count.to_s
count = count + 1
output_file = File.open(new_name, "w")
array.each{|line|
# puts line
if line =~ /xxxxx/
line.sub!(/xxxxx/, File.basename(f))
end
output << line
}
output_file.write(output)
output_file.close
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment