1

I understand that there are approx. 64K possible files in a FAT32 folder. This assumes 8.3 file names. Longer file names take up multiple slots. Therefore, it is difficult to know how many actual directory entries are being used.

I've encountered this limit once in a while because of long file names, not sheer number of files. Is there a way for us to know the actual number of free file-directory spaces in a folder?

1 Answer 1

1

I know of no tool that will let you count the number of directory catalog entry "slots" in use or available in a FAT32 folder. A nice gentleman named Udi Cohen has a C++ utility for sorting filenames in fat32, and you may be able to define a class that that will let you enumerate or get a count of these entries

The limitation is set by the file system. FAT32 can have 65,536 entries. Each file and subdirectory takes from two to thirteen entries, depending on the length of its name.

The FAT32 spec is available here: http://www.microsoft.com/whdc/system/platform/firmware/fatgen.mspx

It gives details on everything, including the directory structure and the way Long File Names (LFNs) are stored in directories.

Basically, there's one directory entry that always holds the short (8.3) version of the file name. If the actual name doesn't fit that mold, then there will be one to twelve more entries, each of which holds 13 bytes of the full name. So a file named "veryverylongname.txt" would take three entries. The first would have the short name, something like "veryve~1.txt", the second would have "veryverylongn", and the third would have "ame.txt".

2
  • Thank you! Using this information, it should be possible to write a program in Perl or the like, that just reads a directory listing and calculates the number of entries used from the lengths of the file names. No need to go low-level. Apr 21, 2013 at 23:20
  • How does this look:#input from dir /b while ($ln=<>) { chop $ln; $nfiles++; $dot=""; $base=""; $ext=""; $ln =~ /([^.]*)(\.)(.*)/; $base = $1; $dot=$2; $ext=$3; $baselen=length($base); $extlen=length($ext); if ($baselen > 8 || $extlen > 3 || $ext =~ /\./) { $totlen=$baselen+$extlen+length($dot); $nent+=int($totlen/13); $nent++ if ($totlen%13 > 0); } } $nent+=$nfiles; $rem=65536-$nent; print "$nfiles file names occupy $nent directory entries. $rem entries remain."; Apr 22, 2013 at 3:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .