DiskUsage: Check Disk Space In Windows 11 Using Command Line

Low storage space on a computer can be daunting. It can either be fixed by moving your data, deleting it, or adding a new hard drive. It is therefore important to know which files consume the most storage.

This can be done using File Explorer, Storage Sense, and other mechanisms. However, in certain scenarios, getting this information for each partition or folder is simpler using the Windows command line.

On Windows 11, you can use the “DiskUsage” command to view the storage details for different partition volumes, folders, and subfolders. This command also allows you to use switches and filter the information that you want to see. For example, you can use the /minFileSize switch to set a minimum file size filter or the /u switch to view a fixed number of items.

The DiskUsage command has been introduced after referencing from the DU command on Linux distros which serves the same storage-space-info purpose.

Note: After having tested out the DiskUsage command-line tool, we found that it is not included in Windows 10. Although it was anticipated to be introduced a few years ago, it now no longer exists and is only available on Windows 11 at the time of writing this post.

View disk space usage from command line

With the DiskUsage command, you only need to enter the prompt and the complete path of the drive or folder that you want to get the information for. Here are the steps to use the DiskUsage command to obtain disk utilization information using Command Prompt:

  1. Press the Windows Key + R to open the Run Command box.

  2. Type in “cmd” and press CTRL + Shift + Enter to run Command Prompt with administrative privileges.

  3. In the Command Prompt, use the following command while replacing [PathToFolder] with the complete path to the drive or folder that you want to view information on:

    DiskUsage [PathToFolder]
    View disk usage from Command Prompt
    View disk usage from Command Prompt

This will now show the complete details for the items inside the specified directory, including the subdirectories. As you can see in the image above, you also get information on the number of items inside each subdirectory and its total size in bytes.

If you want the file and directory size in KBs, KBs, and GBs, then you must use the /h switch at the end of the command, as in this example:

DiskUsage [PathToFolder] /h
View disk usage with file size
View disk usage with file size

View disk usage with minimum file size

As mentioned earlier in this post, you can use certain switches to set filters and view items greater than a specified file size within a drive or a directory. For this purpose, you can use the /minFileSize switch with the DiskUsage command.

Here’s how to set the filters to view files greater than the specified file size:

Note: The specified file size is in bytes. Therefore, you may need to convert the file size from GBs, MBs, and KBs, to bytes. You can use the following conversion numbers:

  • 1 GB = 1073741824 bytes
  • 1 MB = 1048576 bytes
  • 1 KB = 1024 bytes
  1. Press the Windows Key + R to open the Run Command box.

  2. Type in “cmd” and press CTRL + Shift + Enter to run Command Prompt with administrative privileges.

  3. Use the following command to view disk usage details for all files greater than a specific size while replacing [PathToFolder] with the complete path to the drive or folder that you want to view information on, and [FileSize] with the size of the files that you want to see (in bytes):

    DiskUsage /minFileSize=[FileSize] [PathToFolder] /h
    View disk usage greater than specific file size using Command Prompt
    View disk usage greater than specific file size using Command Prompt

In the image above, we viewed all items inside the “D:\Itechtics” directory that were greater than 5 GB. As you can see from the results, only one subdirectory with the name “ISOs” was listed that occupied 73.4 GBs on the disk.

View disk usage for specific number of items

Using the same concept as above, you can also set a filter to the command that will show you a fixed number of items only.

Instead of vetting through hundreds and thousands of items within a directory, you can set the DiskUsage command to show you only the top 5 or top 10 (whichever number you choose) files greater than a specific file size. This can be achieved with the /u switch.

Simply use the following command syntax while replacing the necessary variables within the square brackets []:

DiskUsage /minFileSize=[FileSize] [PathToFolder] /h /u=[ItemsToDisplay]
View disk usage for top items greater than the specified size
View disk usage for top items greater than the specified size

As you can observe from the image above, only 10 items have been displayed. These are the top 10 items in descending order within the “D:\Itechtics” directory that are greater than 1 MB.

View disk usage by file name

On top of the filters that we have already discussed, you can also include the file name that you want to filter. By applying the /n filter, you can include a partial name of the file(s) that you want to display. All files and subdirectories which include that name will be displayed along with their size details.

Here is the command syntax that you can use to view an item within a directory, having a file size greater than that specified, and includes a name, while replacing the necessary variables:

DiskUsage /minFileSize=[FileSize] [PathToFolder] /h /n=[Name]

DiskUsage in Windows 11

As mentioned at the beginning of this post, the DiskUsage command is only available for Windows 11 at the moment.

Using this command, you can view the details for stored items within a drive or directory directly in your command line. This saves you the hassle of going to individual items and then using the Graphical User Interface (GUI), like the Properties window, to view the disk usage details.

This article discusses multiple command-line switches that you can use to set filters, making your searches even more human-readable. To learn more about the DiskUsage command and its switches, type in “DiskUsage /?” into the Command Prompt and learn about the additional switches that you can use.

If you liked this post, Share it on:
Subhan Zafar is an established IT professional with interests in Windows and Server infrastructure testing and research, and is currently working with Itechtics as a research consultant. He has studied Electrical Engineering and is also certified by Huawei (HCNA & HCNP Routing and Switching).

Leave the first comment

Get Updates in Your Inbox

Sign up for the regular updates and be the first to know about the latest tech information