How to reduce the size of a folder index file in NTFS?

I have a folder in NTFS containing tens of thousands of files. I deleted all the files in this folder, save 1. I ran the contig.exe file to defragment this folder, so now it is only in 1 fragment. However, the size of this folder is still 8 MB. This means that there are many gaps in the index. Why is this? If I delete this single file, the index size will automatically be zero. I guess it crashed in the MFT. Is there a way to get NTFS to really defragment the index file by defragmenting it based on the contents of the file? Any API you know about? Contig.exe defragments only the physical file.

+4
source share
3 answers

I guess this is one of the ways that NTFS is like almost any other FS - none of them seem to like compressed directories.

So, you must apply the high-tech method, which involves the use of this advanced language "BAT" :)

collapse.bat

REM Invoke as "collapse dirname" ren dirname dirname.old mkdir dirname cd dirname.old move * ../dirname/ cd .. rmdir dirname.old 
+6
source

In the slack index, but not gap . I am making a distinction to imply that there is technically wasted space, but this is not like NTFS needs to parse 8MB to list / query / regardless of index. He knows where the root of his tree is, and he just has an extra selection. Probably a too detailed answer, given how useless it is.

Fragmentation is probably a separate issue.

+2
source

Take a look at the accepted answer to this question: NTFS performance and large volumes of files and directories

The author provided some undocumented file index fragmentation information that he received from Microsoft technical support during the incident. In the short version, DEFRAG does not defragment the index of the folder, but only the files in this folder. If you want to defragment the file index, you must use the CONTIG SysInternals tool, which is now owned and distributed (free) by Microsoft. The answer gives a link to CONTIG .

+2
source

All Articles