From: Ezra Zygmuntowicz Date: 2005-08-01T12:39:33+09:00 Subject: Re: [rake] excluding dirs with FileList --Apple-Mail-9-678961618 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Jul 31, 2005, at 6:13 PM, Joel VanderWerf wrote: > > How can I construct a FileList that excludes dirs? Not a particular > directory, but _any_ directory? > > I had hoped that #exclude could be passed an object whose #=== method > returned true for a dir (using File#directory?). But #exclude tries to > turn its argument into a string and build up a regex. > > -- > vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407 > require 'find' file_list = [] start_path = "/path/to/directory/" <= the dir to start recursing from. Find.find(start_path) do |file| file_list << path unless test(?d, file) end p file_list This works unless I misunderstand what you are trying to do. See $ ri test for more info. HTH- -Ezra Zygmuntowicz WebMaster Yakima Herald-Republic Newspaper ezra@yakima-herald.com 509-577-7732 --Apple-Mail-9-678961618--