A couple of weeks ago I was carefully deleting an old backup of my data drive. I did a duplicate-file check between the old backup and the live copy and deleted the old copies to the Recycle Bin. It was going just fine and as expected until suddenly I could no longer delete anything. Whenever I tried to delete a file—any file—from the old backup, it would fail.
I examined the Recycle Bin and it occurred to me that it may be because there were simply too many files in the bin. I’m not talking about size, but the number of files. Here’s a few facts about the situation:
- It is a Windows XP system
- The volume with the old backup is FAT32
- The volume with the old backup had 302MB of free space
- The problem occurred once there were 31,594 files in the bin
- The recycled files used 236MB
- The
INFO2
file (which tracks the original filenames of recycled file) is over 24MB - Attempting to delete even one more file would not work regardless of its size
- The Recycle Bin is configured to have no limits on all drives
I tried to look this up, but the closest I can find is information about limits to the size of the Recycle Bin, nothing about the number of files.
Has anyone heard of this? Can anyone confirm that there is a limit to how many files can be stored?
Best Answer
A FAT32 directory can have 65,536 directory entries.
Each file and subdirectory takes from two to thirteen entries, depending on the length of its name.
So in the most optimistic situation your recycle bin could hold 65,536 /2 = 32768 files+directories if they all have filenames in the 8.3 range. (Short names)
Your 31594 files + 53 directories seem to hit the limit.
There are probably a few files that take >2 entries due to longer filenames.
Edit:
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. And because Windows need case sensitivity for the Long File Names (LFNs) it takes a separate directory entry for the LFNs (or muliple if they are longer than 13 characters).
Edit #2:
I did some testing in a VM with Windows XP and a FAT32 drive (with the recycle bin at maximum).
In a
data
directory i created a sub-directorytest
after which i run this batch-file:Resulting in 65534 files (only with short-names). As expected it couldn't add the last two files (
FFFE
andFFFF
) because of the 2 directory entries (.
and..
). So.
and..
only take 2 entries, good to know for later)Next i selected 45000+ files and deleted these in explorer
(took a while to collect the info before deleting :)
Because the filenames in the recycle bin are
De1
,De2
etc. these are long filenames (because of the mixed case). Explorer gave an error after deleting 32765 files.The
dir /a/x
gave me 32767 files and 2 directories.32765 user files (with LFN), an
INFO2
anddesktop.ini
(both without LFN).(32765 * 2) = 65530 + 2 (without LFN) + 2 directory entries = 65534
Mmmm, still 2 short ;)
With 65534 it should be able to add 1 (with LFN) more. So i think Windows might need an extra free entry for some temporary file.
But as you can see the limit is 65530 directory entries of which each file takes up 2.
(So 32765 files because the resulting filenames are mixed case and even less if the extension is larger then 3).
When i tested this the filenames were all
De1
,De2
etc... (the originals where all files without extension) Your filenames have extensions. If they have longer extensions (>3) it could take more entries because Windows does preserve the extension in the recycle bin.But it is indeed strange Microsoft didn't opt for only short-names in the recycle bin because the (original) filenames should be stored in
INFO2
.Edit #3:
I just confirmed that the delete mechanism of Windows does need an extra directory entry.
I did
xcopy e:\recycled\*.* e:\test\ /e/s/h
with a full recycle bin, copying all files (32767 files) out of the recycle bin to a test directory.I could still create 1 file
De_test1.txt
(LFN) ine:\test
. CreatingDe_test2.txt
gave an error.So "Windows delete" should have had enough to create 1 more (LFN) file but because of something internal it can't.
So for normal folders the limit is 65536 -2 for
.
and..
= 65534 entries.and for the recycle bin it is 65536 -2 for
.
and..
and -2 fordesktop.ini
andINFO2
and -2 for a temp.file (?) = 65530 entries
and with 65530 entries it is a maximum of 32765 files (and less if extensions are >3).