Author Topic: Maximum Number Files  (Read 6078 times)

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Maximum Number Files
« on: November 08, 2013, 07:30:04 PM »
Hi Mark,
  What is the maximum number of files that may be saved into a folder?

Thanks
Neil

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: Maximum Number Files
« Reply #1 on: November 08, 2013, 07:41:34 PM »
Hi Neil

A short file name requires 32 bytes space in the directory cluster  so a directory cluster can hold 128 files or directories (in 4k cluster case) but a directory can also use multiple clusters - so the limit depends on the clusters available (as a file grows when more space is needed, a directory entry space also does). On an SD card there are usually many thousands of clusters available, meaning that the number of files in a singel directory can in fact be very large. Subdirectories count as a sincle file entry and then they have their own directory cluster.

Practically however it is best not to have too many file in a directory since directory searches take more time as there are more entries in it.

In the case of FAT16 there is an additional limit to the entries in the root directory since the space is fixed - I think to one cluster. This only applies to the root directory and subdirectories work the same as FAT32.

When working with long file names the space occupied by each entry is at least 64 bytes - and increases depending on how many 32 blocks are required to hold the name string. Therefore LFNs fill up the directory space faster but the rules otherwise are the same - with FAT16 the root directory can hold less LFNs due to this.

Regards

Mark

Offline neil

  • Sr. Member
  • ****
  • Posts: 438
    • View Profile
Re: Maximum Number Files
« Reply #2 on: November 08, 2013, 08:11:20 PM »
Thanks Mark