• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Determine if a filename exists in a LARGE folder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Determine if a filename exists in a LARGE folder


  • Subject: Re: Determine if a filename exists in a LARGE folder
  • From: email@hidden
  • Date: Thu, 14 Jun 2001 19:47:59 -0400

At 12:41 -0400 13 June 2001, Matthew Broms wrote:

>I was going to get a list of filenames in a designated folder and see if
>this list contained "xyz" filename (easy - works well). The problem is that
>this folder is 11 gigabytes in size and currently contains 42,225 items in
>it. Getting a list this size is rather slow and the list is VERY large
>given such a large folder (and there is no way I'm able to break this folder
>down into more manageable sub-folders since this folder is referenced by 3+
>Indigo printers). Does anyone know how to efficiently (that is, reasonably
>fast) check for the mere existence of a filename in such a large folder? My
>experience is that the Mac OS Finder doesn't deal very quickly with folders
>that have such a large number of files. Doing a straight reference to the
>file directly is slow too - in a try statement I did a "set test to info for
>alias fileNamePath" and set it to a default signature on error. This worked
>properly, but just crawled along. Any suggestions?

"info for" slows down seriously when referencing big folders because its toting
up the size of all contained files.

My favorite way to see if a file exists is to try to create an alias to it,
which will fail if it doesn't exist.

My most fully tested version of this technique is as follows:

to fileExists(filename)
try
filename as alias
return true
on error errMsg number eNum
if eNum is in {-35, -37, -43, -120, -1700 } then return false
-- -35 is "Disk wasn't found", -37: "Bad name for file",
-- -43: "File wasn't found", -120: "Folder wasn't found",
-- -1700: "Can't make [file specification] into an alias"
error errMsg number eNum -- repropagate other errors.
end if


--
Scott Norton Phone: +1-703-299-1656
DTI Associates, Inc. Fax: +1-703-706-0476
2920 South Glebe Road Internet: email@hidden
Arlington, VA 22206-2768 or email@hidden


  • Follow-Ups:
    • Re: Determine if a filename exists in a LARGE folder
      • From: John W Baxter <email@hidden>
  • Prev by Date: Re: Graphics Converter 4.0.8
  • Next by Date: Re: Question about "info for" command
  • Previous by thread: RE: Determine if a filename exists in a LARGE folder
  • Next by thread: Re: Determine if a filename exists in a LARGE folder
  • Index(es):
    • Date
    • Thread