From: Stuart Clarke Date: 2010-01-08T23:28:22+09:00 Subject: Re: Setting recursion depth I think this code will work best for me. On another matter, is there an easier way to ignore files and just show folders at present I am doing (not valid code) if File.file?(path) else puts File.dirname(path) end Many thanks Fleck Jean-Julien wrote: > Hello, > >> Basically I want to be able to specify the depth my script will work so >> if the depth is 4, the script will look at all items from the root to 4 >> folders deep e.g > > Something like Dir.glob(['*','*/*','*/*/*','*/*/*/*']) should do > without being too "manual" > > Or if you like to change the depth: > > def search_to_depth(n) > array = Array.new(n) {|i| '*' + '/*'*i} > Dir.glob(array) > end > > Cheers, -- Posted via http://www.ruby-forum.com/.