I was wondering if there were a way to use Dir.glob to grab only
directories. After searching google for a bit I found ways to pull only
file listings, but couldn't find one for just directories.
Currently, I'm using FileTest.directory?(dir) before running any
operations to test for a directory.
I was wondering if there were a way to use Dir.glob to grab only
directories. After searching google for a bit I found ways to pull only
file listings, but couldn't find one for just directories.
Currently, I'm using FileTest.directory?(dir) before running any
operations to test for a directory.
On Jul 3, 2:09 pm, Mario Gr <mflor...@gmail.com> wrote:
Hi,
I was wondering if there were a way to use Dir.glob to grab only
directories. After searching google for a bit I found ways to pull only
file listings, but couldn't find one for just directories.
Currently, I'm using FileTest.directory?(dir) before running any
operations to test for a directory.
For deep hierarchies it may be more efficient to use Find because you avoid creating a large Array with lots of file names most of which you do not want.
# untested
require 'find'
DOTS = %w{. ..}
Find.find base_dir do |f|
next if DOTS.include?(File.basename(f)) || !test(?d, f)
puts "A dir which is not . or ..: #{f}"
end
Kind regards
robert
···
On 03.07.2009 20:43, Andrea Fazzi wrote:
Mario Gr wrote:
Hi,
I was wondering if there were a way to use Dir.glob to grab only
directories. After searching google for a bit I found ways to pull only
file listings, but couldn't find one for just directories.
Currently, I'm using FileTest.directory?(dir) before running any
operations to test for a directory.
On Jul 3, 10:48 pm, Intransition <transf...@gmail.com> wrote:
On Jul 3, 2:09 pm, Mario Gr <mflor...@gmail.com> wrote:
> Hi,
> I was wondering if there were a way to use Dir.glob to grab only
> directories. After searching google for a bit I found ways to pull only
> file listings, but couldn't find one for just directories.
> Currently, I'm using FileTest.directory?(dir) before running any
> operations to test for a directory.
On Jul 3, 2:09 pm, Mario Gr <mflor...@gmail.com> wrote:
> Hi,
>
> I was wondering if there were a way to use Dir.glob to grab only
> directories. After searching google for a bit I found ways to pull only
> file listings, but couldn't find one for just directories.
>
> Currently, I'm using FileTest.directory?(dir) before running any
> operations to test for a directory.