1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

DIR /G question

Discussion in 'Support' started by Jim Cook, Nov 30, 2009.

  1. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    605
    Likes Received:
    0
    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.
     
  2. Jim Cook

    Joined:
    May 20, 2008
    Messages:
    605
    Likes Received:
    0
    TCC 11.00.34 Windows XP [Version 5.1.2600]
    TCC Build 34 Windows XP Build 2600 Service Pack 3

    On Mon, Nov 30, 2009 at 3:48 PM, Jim Cook <> wrote:

    --
    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.
     
  3. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,730
    Likes Received:
    80
    It also (dramatically) slows down DIR & PDIR. I don't think the minor
    benefit outweighs the major pain.

    Rex Conn
    JP Software
     

Share This Page