Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you reduce the size of a folder's index file in NTFS?

Tags:

ntfs

I have a folder in NTFS that contains tens of thousands of files. I've deleted all files in that folder, save 1. I ran contig.exe to defragment that folder so now it's in 1 fragment only. However, the size of that folder is still 8MB in size. This implies that there's a lot of gap in the index. Why is that? If I delete that one file, the size of the index automatically goes to zero. My guess is because it gets collapsed into the MFT. Is there any way to get NTFS to truly defragment the index file by defragmenting it based on the content of the file? Any API that you're aware of? Contig.exe only defragment the physical file.

like image 556
MrB Avatar asked Dec 30 '22 08:12

MrB


1 Answers

I guess this is one way in which NTFS is just like almost every other FS - none of them seem to like shrinking directories.

So you should apply a high-tech method that involves using that 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
like image 139
Mike G. Avatar answered Mar 03 '23 06:03

Mike G.