• 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: Identify image file count in directory
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Identify image file count in directory


  • Subject: Re: Identify image file count in directory
  • From: "Gary L. Wade" <email@hidden>
  • Date: Fri, 13 Nov 2015 08:54:35 -0800

Try going down a level to the BSD layer APIs for directory contents traversal.
--
Gary L. Wade (Sent from my iPad)
http://www.garywade.com/

> On Nov 13, 2015, at 8:28 AM, Jonathan Taylor <email@hidden> wrote:
>
> Hi all,
>
> I want to be able to identify quickly (programatically) how many image files reside in a particular directory. At present I call:
>  [NSFileManager defaultManager] contentsOfDirectoryAtPath:dir error:nil];
> and then examine the type suffixes (which in comparison is very quick). When looking at a directory over a network or on an external drive, the NSFileManager call can take several seconds for a directory containing 18k files of which half are images.
>
> These sorts of numbers are in fact a common use case for me, and I would like to avoid this delay. This is for preview information in an NSOpenPanel, so I don't want to make things this unresponsive - but at the same time it is very useful to have access to this information for the preview.
>
> Can anybody advise on a quicker way of achieving what I want to achieve? The fact that 'ls' takes almost as long makes me think this is probably a fairly insurmountable problem, but at the same time the quantity of information transferred (of the order of 200k of data) should not take 2 seconds to transfer, so in that sense it doesn't seem unreasonable to try and see if there is a faster way.
>
> I would prefer to get the filenames themselves, but I could settle for just a count of the total number of files (of any kind) in the directory *and* the ability to get the paths of just the first few files in the directory, if there might be a faster way of doing that.
>
> Thanks for any suggestions
> Jonny

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: Identify image file count in directory
      • From: Jonathan Taylor <email@hidden>
References: 
 >Identify image file count in directory (From: Jonathan Taylor <email@hidden>)

  • Prev by Date: Identify image file count in directory
  • Next by Date: Images in NSOutlineView disappear on dataReload
  • Previous by thread: Identify image file count in directory
  • Next by thread: Re: Identify image file count in directory
  • Index(es):
    • Date
    • Thread