Windows 10 to get a built-in command-line disk space analyzer - Windows Basics

Latest

Wednesday, December 16, 2020

Windows 10 to get a built-in command-line disk space analyzer

Microsoft is working on a built-in 'Use Disk' command line utility that reports how much disk space a directory uses.

Over time, it's common to run out of storage space and not know which programs or files are using up hard drive space. Previously, users needed to download free tools like TreeSize to list the directories using the most space.

While playing with the new Windows 10 Insider versions 20277 and 21277 released last week, BleepingComputer discovered that Microsoft had been silently introducing a new DiskUsage utility. This utility can scan your entire drive or specified folders and report how many each folder is in use.

DiskUsage is located in C:\Windows\System32\diskusage.exe and will display the user guide when entering diskusage /?, As shown below.


This program is in the early stages of development, some features are not working as expected and some misspellings in the manual.

For those interested, the complete instructions for use are below:

DiskUsage - Disk Usage

 

Description: Summarize disk usage recursively for the given directory.

Usage      : diskusage [Options] [Directory]

Options    :

    /a, /systemAndReserve    displays size for system files and reserved space

    /c, /csv                 displays in csv format

    /d, /maxDepth=N          displays directory information only if it is N or

                             fewer levels below command line argument

    /e, /minFileSize=SIZE    displays directory information only if its FileSize

                             is greater or equal than SIZE

    /f, /minSizeOnDisk=SIZE  displays directory information only if its SizeOnDisk

                             is greater or equal than SIZE

    /g, /displayFlag=FLAG    specifies the flags value to determin which column(s) to display

                             column          value    description

                             SizeOnDisk      0x001    the on disk size

                             FileSize        0x002    the end of file size

                             SizePerDir      0x004    sum of SizeOnDisk for top level child

                             Files           0x008    number of child files

                             ChildDirs       0x010    number of child directories

                             FilesPerDir     0x020    number of top level child files

                             DirsPerDir      0x040    number of top level child directories

                             CreationTime    0x080    file creation timestamp

                             LastAccessTime  0x100    file last access timestamp

                             LastWriteTime   0x200    file last write timestamp

                             Attributes      0x400    file attributes

    /h, /humanReadable       displays size in human readable format

    /i, /iniFile=FILE        takes all the parameters from an INI file.

                             NOTE: SCENARIO name must be speificed via /j (/scenario)

    /j, /secnario=SCENARIO   specifies the scenario name for the INI file

    /l, /allLinks            count all hardlinks separately (By default, files with multiple

                             hardlinks are counted only once towards the first link name)

    /m, /multipleName        count only files with more than one link names

    /n, /nameFilter=FILTER   count only files whose name matches the name filter

    /p, /preferredPath=PATH  count files with multiple link names towards the first link that's

                             under PATH if it exists

                             NOTE: This options must not be specified togerther

                             with /l (/allLinks)

    /q, /virtual             recurse into virtual directories

    /r, /skipReparse         skip recursing into reparse directories

    /s, /skipResurse         skip recursing into child directories when calculating sizes

    /t, /TopDirectory=N      displays Top N directories by SizeOnDisk in descending order

    /u, /TopFile=N           displays Top N files by SizeOnDisk in descending order

    /v, /verbose             displays verbose error information

    /x, /clearDefault        do not display the default selected columns

Test the new DiskUsage utility

Microsoft's new DiskUsage tool is in the early stages of development, so it has a bit of roughness around the edges. With that said, BleepingComputer decided to give it a try and see how it works.

By default, when running DiskUsage, it will report file and folder sizes in bytes, which is not as useful as displaying sizes in MB, GB, etc. Thankfully, Microsoft has included an a / h argument to show the human-readable size we'll use in our usage examples below.

When we ran this test on a virtual machine we didn't have a lot of data or large programs installed, so we tested it with the C: \ Windows directory.

Since this tool requires administrative privileges, you must first open an elevated Windows 10 command prompt before using diskusage.exe otherwise it will show an error.

To see folders in C: \ Windows that are larger than 1 GB in size, we ran the following command:

diskusage /minFileSize=1073741824 /h c:\windows

As you can see below, DiskUsage has listed all folders, including the C: \ Windows folder, which are larger than 1 GB in size.

DiskUsage also includes a feature that lists the top N (number) folders on the drive or in a specific directory. To do this, use the command / t = [number] as follows:

diskusage /t=5 /h c:\windows

Unfortunately, the output of this command is not as expected. As you can see below, it shows an ordered list of 5 folders, but based on our previous commands, they are not the directories we expected.


We guess the above command shows the largest directories, without looking at the files in their subdirectories.

DiskUsage also includes other features like listing top size files using / u option, as shown in following command:

diskusage /u=5 /h c:\windows

As you can see below, instead of showing the top five folders, DiskUsage displays the five largest files.

Other features included in DiskUsage include creating a configuration file that contains the options you want to use automatically, customizing the output, and the ability to skip different types of folders.

As stated earlier, DiskUsage is still in its early stages and there is no information as to when it will be available. You can test it out now by installing the latest Windows 10 Insider builds.

No comments:

Post a Comment