19

How many files can a folder contain? I have 30k folders inside 1 folder. Each of the folders has 1 image file. Is there a limit on the number of files a folder can store?

I am using Windows Server 2003, IIS6.

4 Answers 4

21

Note: Assuming NTFS, as no one in their right mind would use FAT for anything else than USB thumb drives or memory cards, let alone on a server (ok, that thought is scary).

Yes, there is a limit. Storing more files than particles in the universe may prove impractical. However, the actual limit is far lower.

NTFS has a maximum of 4,294,967,295 (232 − 1) files per volume. A few of those are already used by the file system itself and folder should count as files too.

30,000 aren't that many files, actually. But Microsoft recommends that you turn off auto-generation of DOS-compatible short names if you move past 300,000 as finding a unique short name gets difficult then.

3
  • Hmm the recommendation applies to NT 3.5. It does not mention any new Operating Systems.
    – Ganesh R.
    Feb 3, 2010 at 14:40
  • 2
    That fact hasn't changed since then. Short name generation is still there and the underlying problem of finding a short name still remains once there are too many of them—simply because they are ... well ... short :-)
    – Joey
    Feb 3, 2010 at 17:58
  • I was looking for this info. I just had to drop to DOS 8.3 short names for a program I'm working with in which I exceeded a filepath character limit. I started thinking there could be some limitations. Then I realized that after a few similar files they start using 4 character hashes. There are (26+10)^4=1679616 possible names then. I tried stumping it by renaming a file to another file's shortname, but it converted it behind the scenes and basically said "File Exists. LooooongName (2) instead?". Since I don't plan to get anywhere near 300000, I'll be fine! Interesting stuff! Sep 10, 2014 at 4:10
16

There's no practical limit on the combined sizes of all the files in a folder, though there may be limits on the number of files in a folder. More importantly, there are limits on individual file size that depend on what filesystem you're using on your hard disk. (The "filesystem" is nothing more than the specification of exactly how files are store on disk.)

Let's break this down by file system:

•FAT aka FAT16

FAT, for File Allocation Table, is the successor to the original FAT12 filesystem that shipped with MS-DOS many, many years ago.

◦Maximum disk size: 4 gigabytes

◦Maximum file size: 4 gigabytes

◦Maximum number of files on disk: 65,517

◦Maximum number of files in a single folder: 512 (if I recall correctly, the root folder "/" had a lower limit of 128).

•FAT32

"There's no practical limit on the combined sizes of all the files in a folder, though there may be limits on the number of files in a folder."FAT32 was introduced to overcome some of the limitations of FAT16.

◦Maximum disk size: 2 terabytes

◦Maximum file size: 4 gigabytes

◦Maximum number of files on disk: 268,435,437

◦Maximum number of files in a single folder: 65,534

•NTFS

NTFS, or "New Technology File System" introduced with Windows NT, is a completely redesigned file system.

◦Maximum disk size: 256 terabytes

◦Maximum file size: 256 terabytes

◦Maximum number of files on disk: 4,294,967,295

◦Maximum number of files in a single folder: 4,294,967,295

Note that when I say "disk" above, I'm really talking about "logical" disks, not necessarily physical. No one makes a 256 terabyte disk drive, but using NTFS you can treat an array of disk drives as a single logical disk. Presumably if you have enough of them, you can build a huge logical drive.

Also note that the NTFS's 256 terabyte limitation may well simply be an implementation restriction - I've read that the NTFS format can support disks up to 16 exabytes (16 times 1,152,921,504,606,846,976 bytes).

Source

3
  • 1
    You may want to site your source.
    – user1931
    Feb 3, 2010 at 13:55
  • If max disk size for FAT32 is 256 terabytes, then why the limit of 32 GB for making a partition?
    – Ganesh R.
    Feb 3, 2010 at 14:37
  • @GaneshR. it's only the artificial limit of the format program in Window XP and up. All other formatters have no problem creating a large FAT32 partition. Probably because they want people to change to NTFS. That's a goold thing, because NTFS are much better than FAT32 at handling files: bigger drives, bigger file sizes, better fault tolerance (due to journal), smaller cluster size for big drives, faster file seeking/opening (due to the B-tree structure), better performance for very big files and very small files... There's almost no reason to use a big FAT32 partition nowadays
    – phuclv
    Mar 16, 2017 at 3:54
2

You can only have a maximum of 65535 files in the windows temp directory, otherwise the .Net Framework method Path.GetTempFileName will stop working. Deleting previous temporary files will allow it to work again until the limit is reached once more

See: Path.GetTempFileName

-1

If you're using NTFS, then no, there is no real limit.

Performance will suffer in other ways: trying to open a folder with 30k sub-folders will suck enormous amounts of time.

FATXX has limits.

Other modern file systems, no real limit.

4
  • 1
    Where do you get the idea that 30k subfolders "sucks enormous amounts of time"? Opening such a folder (with 50k subfolders) takes a second in Explorer, another second to sort correctly. In FAR Manager it takes about 1 second to open that folder.
    – Joey
    Feb 3, 2010 at 13:59
  • 2
    I can see why he would say that. If you are using thumbnail view, Windows will attempt to display a thumbnail of the contents of each folder. Though in thumbnail view you're unlikely to see more than a dozen or so folders on screen at any one time. Feb 3, 2010 at 14:45
  • Yes, I though of that after I'd written this. A view of folders won't take long. Thumbnail view... will.
    – SuperMagic
    Feb 3, 2010 at 16:40
  • thumbnails should be disabled on big folders
    – phuclv
    Mar 16, 2017 at 3:56

You must log in to answer this question.