Jens Riedel wrote: > Hello, > > I'm quite new to Ruby. > I'd to walk through a directory tree and edit all jsp files in there. > > I do it this way: > > def editDirectory(path) > Dir.entries(path).each { |filename| > next if filename =~ /^\.+$/ > currFile = path + "/" + filename > if(File.stat(currFile).directory?) > editDirectory(currFile) > elsif(filename =~ /(.+)\.jsp$/) > # ... do something with the file > end > } > end > > I'd like to know if there is a more professional or more "ruby-like" > way to do this... > > Thanx for every hint, > Jens require 'find' def edit_directory(dir) Find::find(dir) do |f| if /\.jsp$/i =~ f and File.file? f # do something with f end end end Kind regards robert