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

Identify image file count in directory


  • Subject: Identify image file count in directory
  • From: Jonathan Taylor <email@hidden>
  • Date: Fri, 13 Nov 2015 16:28:31 +0000

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: "Gary L. Wade" <email@hidden>
  • Prev by Date: Re: Voiceover support
  • Next by Date: Re: Identify image file count in directory
  • Previous by thread: Re: Voiceover support
  • Next by thread: Re: Identify image file count in directory
  • Index(es):
    • Date
    • Thread