DIR /G does not appear to report accurately for small files on NTFS
drives (at least).
It seems that for small files, they do not occupy a cluster or
separate data storage area. When I delete them and look at free space
before and after the operation, there is no more free space.
I believe using NtQueryInformationFile with FILE_STANDARD_INFORMATION
and looking at .AllocationSize might be more accurate than what DIR /G
appears to be doing: rounding up to an allocation unit size.
When deleting below, the del command appears to say when bytes are
freed, but is mute when none actually become free.
I also tested on a FAT and FAT32 drives which del claimed to have
recovered 32,768 and 4,096 bytes in spite of %@diskfree not changing.
D:\>echo hi > foobar
D:\>echo %@diskfree[d:]
528251428864
D:\>*dir /g/k/m foobar
2009-11-30 15:35 4,096 foobar
D:\>del foobar
Deleting D:\foobar
1 file deleted
D:\>echo %@diskfree[d:]
528251428864
D:\>for /l %h in (1,1,100) do echo line number %h >> foobar
D:\>*dir /g/k/m foobar
2009-11-30 15:36 4,096 foobar
D:\>echo %@diskfree[d:]
528251424768
D:\>del foobar
Deleting D:\foobar
1 file deleted 4,096 bytes freed
D:\>echo %@diskfree[d:]
528251428864
--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.
drives (at least).
It seems that for small files, they do not occupy a cluster or
separate data storage area. When I delete them and look at free space
before and after the operation, there is no more free space.
I believe using NtQueryInformationFile with FILE_STANDARD_INFORMATION
and looking at .AllocationSize might be more accurate than what DIR /G
appears to be doing: rounding up to an allocation unit size.
When deleting below, the del command appears to say when bytes are
freed, but is mute when none actually become free.
I also tested on a FAT and FAT32 drives which del claimed to have
recovered 32,768 and 4,096 bytes in spite of %@diskfree not changing.
D:\>echo hi > foobar
D:\>echo %@diskfree[d:]
528251428864
D:\>*dir /g/k/m foobar
2009-11-30 15:35 4,096 foobar
D:\>del foobar
Deleting D:\foobar
1 file deleted
D:\>echo %@diskfree[d:]
528251428864
D:\>for /l %h in (1,1,100) do echo line number %h >> foobar
D:\>*dir /g/k/m foobar
2009-11-30 15:36 4,096 foobar
D:\>echo %@diskfree[d:]
528251424768
D:\>del foobar
Deleting D:\foobar
1 file deleted 4,096 bytes freed
D:\>echo %@diskfree[d:]
528251428864
--
Jim Cook
2009 Saturdays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Sunday.