From: rio4ruby Date: 2006-07-27T14:50:09+09:00 Subject: Re: Finding files in a directory and regexp One could use Rio (rio.rubyforge.org) This would find the files which start with '100_' rio("/Users/alamb/_Current-Work/fiches").files(/^100_/) do |path| ... end To include files in subdirectories that start with '100_' use: rio("/Users/alamb/_Current-Work/fiches").all.files(/^100_/) do |path| ... end Hal Fulton wrote: > Alexander Lamb wrote: > > Hello, > > > > I am doing something like this: > > > > Find.find("/Users/alamb/_Current-Work/fiches") do |path| > > if(path =~ /100_/) > > ... > > > > In order to get all the files of the directory which have "100_" in the > > name. > > > > Two questions: > > > > 1) Is there a way to use the find method to directly achieve this? > > 2) I tried a Regexp with /^100_/ to say "files starting with '100_' " > > but it doensn't seem to work. > > I don't usually use Find... Dir is fairly powerful. > > Dir["100*"] # all 100-type files in current dir > Dir["**/100*"] # all in this tree (correct syntax??) > > > Hal