This is a little known reghack:
When Windows stores files in a folder on an NTFS partition, it still creates so-called 8.3 file names for compatibility with 16-bit Windows programs.
When a folder has more than 4000 file entries, it becomes noticeable that access performance decreases. When the folder has more than 32000 files, it can take up to seconds to create a new file.
This is caused by the fact that for files with long file names, Windows is generating short file names in the old DOS 8.3 format.
Suppose you have a folder with the following files:
www.test.org - pic1.jpg www.test.org - pic2.jpg
The corresponding 8.3 file names are generated when creating the files are:
This is all cool and swell, until you have more than 9 files that start with the same six characters.
When that limit is reached, Windows starts to generate random hexadecimal characters for positions 3-6, like so:
However, after generating this short file name, Windows still needs to check if another file exists in that folder with a name with those 6 starting characters. If it finds such a file, it would generate the ~2 variant, and checks if that one exists. And so on…
You can imagine, with many files in a folder, this checking can take a substantial amount of time.
If you, like most people, do no longer need 16-bit compatibility (who uses those programs still?), you can switch this behavior off in the registry.
From then on, Windows will only store the long file names, which need to be unique in the folder anyway.
This can be a tremendous performance gain (I can speak out of experience with folders with more than 100.000 entries – which is bad idea anyway, but sometimes, in automated environments, programs generate that amount of data).
Here is the command to switch the behavior off:
reg add HKLMSYSTEMCurrentControlSetControlFileSystem /v NtfsDisable8dot3NameCreation /t REG_DWORD /d 1
And here is the code to revert the change:
(Windows XP and older have an initial value of 0, see below for Windows 7 and up):
reg add HKLMSYSTEMCurrentControlSetControlFileSystem /v NtfsDisable8dot3NameCreation /t REG_DWORD /d 0
(Windows 7 has an initial value of 2!):
reg add HKLMSYSTEMCurrentControlSetControlFileSystem /v NtfsDisable8dot3NameCreation /t REG_DWORD /d 2