Hi,

As part of my "training" with Ruby, I decided to try and get a list
of files, then save based on size to a new folder for burning onto
CD. When I do this using "Find", I can get the files but if there
are any bundles or packages in the folder, those are being treated
like ordinary folders and Find is burrowing down into the package
contents. This behavior I do not want.

Here is the code I am using (borrowed from a book):

require "find" def findfiles(dir, name)
  list = [] Find.find(dir) do |path|
    Find.prune if [".",".."].include? path case name
       when String
   list << path if File.basename(path) == name
       when Regexp
   list << path if File.basename(path) =~ name
    else
       raise ArgumentError
    end
  end list
end

So when this finds a Numbers file, the result it gives is:

.../filesizeTest/401k allocation.numbers
.../filesizeTest/401k allocation.numbers/QuickLook
.../filesizeTest/401k allocation.numbers/QuickLook/Thumbnail.jpg
.../filesizeTest/401k allocation.numbers/index.xml.gz
.../filesizeTest/401k allocation.numbers/document-thumbnail.tiff
.../filesizeTest/401k allocation.numbers/Contents
.../filesizeTest/401k allocation.numbers/Contents/PkgInfo

I understand why this is happening (bundles and packages are folders
which the Mac OS treats like a file, but Ruby does not know about
this). The only "easy" solution that I can see to this is to use
rb-appscript and get the folder contents using Applescript (which
presumably *would* know to treat a package/bundle app as a file,
not a folder). I haven't tried this yet, and if anyone has, let
me know if it works!

Has anyone else dealt with this problem and, if so, what solution
did you use?

TIA

vince

ruby 1.86
mac OS X 10.5.2
-- 
Posted via http://www.ruby-forum.com/.