On Mon, Apr 21, 2008 at 9:10 AM, Clement Ow
<clement.ow / asia.bnpparibas.com> wrote:
>
>  >    folders.each do |folder|
>  >      Find.find(folder + "/") do |file|
[...]
>  >      end
>  >    end
>
>  Currently, when i specify the folder path to be C:/Test, it begins
>  searching for files that are in C:/Test/New as well. So is there any way
>  that the command doesnt traverse the folders to match the regexp? (i.e
>  only match C:/Test if the path specified is C:/Test)Thanks in advance!

You mean you want just to list the first level, without recursively processing
the subfolders? Then you don't need the Find module, you can use:

Dir.glob(folder + "/*") do |file|
# This will list subfolders too, so you can skip them with:
next if File.directory? file
[...]
end

If you want to do more fine grained pruning of which subfolders to recurse
you can use Find.prune. This is an example to achieve the same as above:

irb(main):046:0> Find.find("/home/jesus/") do |file|
irb(main):047:1* if ((File.directory? file) && !(file == "/home/jesus/"))
irb(main):048:2> Find.prune
irb(main):049:2> end
irb(main):050:1> puts file
irb(main):051:1> end

Hope this helps,

Jesus.