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 Outputs: > ["Work/Icon\r", "Work/cvs", "Work/git", "Work/mirrors", "Work/misc", "Work/p4", "Work/svn"] glob "*" outputs all "visible" files (non-dot files) but it can do a whole lot more too. ri Dir.glob for more details.