I mixed up sub-folders and files. I meant to say that I want to sort files before sub-folders (so that the folder that a file resides in comes right before the file in the list). I tried the posted code, but I couldn't get it to run. Some String comparison problem. ---------output--------------- SetOutPath jruby-1.0.3 SetOutPath Djruby-1.0.3/.. C:/ruby/jruby-1.0.3/lib/ruby/1.8/find.rb:45:in `find': comparison of String with String failed (ArgumentError) from :1:in `catch' from C:/ruby/jruby-1.0.3/lib/ruby/1.8/find.rb:38:in `find' from :1 --------------end output------- > IIRC Find.find does sort sub folders before files. To me your code > seems pretty complex and I believe the major problem is that you check > the same directory over and over again for exclusion because you use > File.basename. Can't you just do this? > > Find.find base do |path| > if File.directory? path > if excludes.include? path > Find.prune > else > puts "SetOutPath #{path}" > end > else > puts "File #{path}" > end > end > > Kind regards > > robert