"Offering free computer help, hints, and tips to the Internet populace." Now with over 3,820 tips!

Windows XP and DOS

Unix Du (Disk Usage Command)

SUMMARY: This Windows XP - Windows 7 DOS replacement for the Unix du command determines the disk space used in various directories, and can output to CSV for import into Excel.

Most Unix operating systems come with a du command for users and system administrators to help determine which directories use the most space on a hard drive or other media. This is useful if file space is getting low and one needs to determine where to start looking for files to remove and/or archive.

The Sysinternals website, part of Microsoft TechNet, offers a free alternative to the disk usage command, and runs under Windows XP, Windows Vista, and Windows 7 (not tested in Windows 8). Simply download the zip file du.zip, unzip the executable inside to your main Windows directory, and you can check disk usage via the command line:

C:\>du .

This will display disk usage in the current directory and subdirectories. Example output:

Du v1.4 - report directory disk usage
Copyright (C) 2005-2011 Mark Russinovich
Sysinternals - www.sysinternals.com

Files: 1147
Directories: 253
Size: 252,143,334 bytes
Size on disk: 256,487,616 bytes

(Note that the period is required if you do not attach any other command line options).

To remove the Sysinternals banner:

C:\>du -q

To skip recursion so subdirectory disk usage is not shown:

C:\>du -n

To recurse only n level(s) of directories:

C:\>du -l [LEVEL]

For example, to recurse only 2 levels of directories:

C:\>du . -l 2

The -v parameter works similar to the Unix du command in that it will display the usage of each recursed directory in kilobytes. For example, to display the disk usage of each Internet Explorer folder inside the Program Files hierarchy:

C:\> du -q -v "c:\program files\internet explorer"
213 c:\program files\internet explorer\en-US
0 c:\program files\internet explorer\SIGNUP
4,822 c:\program files\internet explorer

Files: 31
Directories: 2
Size: 4,937,898 bytes
Size on disk: 5,009,408 bytes

Attach the -c parameter to display output in CSV (Comma Separated Values) format, useful for importing into Microsoft Excel. For the above example:

C:\> du -q -v -c "c:\program files\internet explorer"

213,"c:\program files\internet explorer\en-US"
0,"c:\program files\internet explorer\SIGNUP"
4822,"c:\program files\internet explorer"

You can also display the file size of only selected files in the current directory and subdirectories. For example, the following command line checks for files starting with news and displays only the disk space used of such files:

C:\documents>du -q news*

To download the file, visit the following link:

* Sysinternals du

Return to the Windows XP and DOS page.

Print this tip

Get the Newsletter

blog comments powered by Disqus

Thanks For Sharing!

Newest Tips:

Windows 8
Tweak the Explorer Navigation Pane
Windows 8
Stop Rearranging My Windows!
Buying a Digital Camera
[MODIFIED] Hidden Costs with Higher Megapixel Cameras
Windows 8
Resize Start Screen Tiles

Follow Us!

About MalekTips and the Author

The MalekTips website was created in 1998 by Andrew Malek of Envision Programming. The page's goal is to freely disperse computer-related tips, hints, and informative articles. Tips are organized to be easy to find, and are presented clearly, in easy-to-understand language. MalekTips also provides information and links to public-domain, open source, freeware, shareware, and commercial software available for download.