From: 7stud -- Date: 2009-02-05T16:58:22+09:00 Subject: Re: Return actual files only not directories, using Pathname Brian Wallace wrote: > I'd like to use Pathname, to return only actual filenames in the > array... > For instance , using FileList.. You can just do this: > > FileList["*.*"] > FileList? I can't find anything in the ruby docs about FileList. google doesn't help either. > Does anyone have any tips on how I could use Pathname to return files > only, > and not directories? Just separate out the files after you retrieve all the file names: require "pathname" pn_obj = Pathname.new("./") file_objs = pn_obj.children dirs = [] files = [] file_objs.each do |obj| if obj.directory? dirs << obj else files << obj end end -- Posted via http://www.ruby-forum.com/.