# JDGui_noComments.rb def treeReplace(dir, filename, search, replace) fcount = 0 Dir["#{dir}/*"].each do |fd| if File.directory?(fd) fcount += treeReplace(fd, filename, search, replace) else if fd =~ filename text = File.read(fd) if text =~ search File.open(fd, 'w') {|f| f << text.gsub!(search, replace)} puts "#{fd}... updated" fcount += 1 end end end end return fcount end # Main program # if __FILE__ == $0 if ARGV.size < 1 puts "Usage: #{$0} <dir>" exit end dir = ARGV[0].dup dir.gsub!(/\\/, "/") # MS-DOS/Microsoft Windows style path compatible puts treeReplace(dir, /\.java$/, /^\/\* [ \d]{1,4} \*\/ ?/, "").to_s() + " file(s) updated" end
Mañana la versión PowerShell que terminé usando... mas sencillo para entornos Windows Seven porque ya viene como parte del SO.
No hay comentarios:
Publicar un comentario