Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 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".

share|improve this answer
    
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. –  Paul Emmons Apr 21 '13 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."; –  Paul Emmons Apr 22 '13 at 3:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.