From: Robert Klemme Date: 2010-08-23T17:55:09+09:00 Subject: Re: directory listing without . and .. 2010/8/23 Ryan Davis : > On Aug 22, 2010, at 23:40 , Rajarshi Chakravarty wrote: >> Hi, >> How can I get an array of all legitimate sub directories in the current >> directory? >> >> path = "D:/Traffic" >> Dir.chdir(path) >> >> This gives 2 extra entries "." and ".." >> Dir.open(stationDir).entries.reject{|f| File.file?(f)} > > In all my years of ruby I don't think I've ever used Dir.open(...).entries. I almost _always_ use Dir.glob (aka Dir[...]). I also almost always use the block form for chdir. > > Dir.chdir("/Users/ryan") do >  p Dir[File.join("Work", "*")] > end And the chdir isn't even needed here as far as I can see. This should do the job: dirs = Dir[File.join(path, '*')].select {|x| File.directory? x} Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/