From: zdennis Date: 2006-03-22T05:53:12+09:00 Subject: Re: Find.find and files in cwd rtilley wrote: > James Edward Gray II wrote: > >> On Mar 21, 2006, at 1:18 PM, rtilley wrote: >> >>> I can use Find.find(Pathname.getwd) to get an array of all file >>> paths recursively, but how do I get only the files in the cwd (do >>> not recurse into sub-directories)? >> >> >> >> Try: >> >> Dir["#{Dir.getwd}/*"] > > > Yes, that helps... thank you. Perhaps I'm using it wrong though. When > trying to extract files with File.file? or links with File.link? like this: > > Dir["#{Dir.getwd}/*"].each do |path| > if File.file?(path) > puts path > end > end > > I get the whole directory listing (files, links, folders, etc.) > To get only normal files try: Dir["*"].delete_if{ |e| not File.file?( e ) } To get only directories try: Dir["*"].delete_if{ |e| not File.directory?( e ) } To get only links try: Dir["*"].delete_if{ |e| not File.link?( e ) } Zach