DISKUSE - CMD
Overview
The DISKUSE
command in Windows CMD is a utility designed to analyze and display the disk usage of a directory and its subdirectories. It helps users manage disk space by providing detailed information about the amount of space each folder consumes, making it particularly useful in environments where disk space management is critical, such as on servers or in development environments with limited storage.
Syntax
The basic syntax for the DISKUSE
command is as follows:
DISKUSE [drive:][path] [options]
[drive:][path]
specifies the drive and directory for which disk usage should be calculated. If no path is given, the command uses the current directory.
Options/Flags
-
/s
– Include subdirectories in the output. Displays the size for each subdirectory found in the specified path. -
/n
– Displays the size in numerical format for easier scripting and processing. -
/h
– Provides output in a human-readable format, using KB, MB, GB for easier comprehension. -
/v
– Verbose mode. Outputs detailed information about each directory’s contents and the disk space they occupy. -
/q
– Quiet mode. Limits the output to only total usage, suppressing individual item details.
Each option modifies the command’s output to suit different needs, from detailed examinations of disk usage to quick summaries.
Examples
-
Basic Usage:
Display disk usage of the current directory without subdirectories.DISKUSE
-
Include Subdirectories:
Show disk usage for all directories and subdirectories on drive C:DISKUSE C:\ /s
-
Human-Readable Format:
Display disk usage in a user-friendly format with subdirectory details.DISKUSE C:\ /s /h
-
Numerical and Quiet Output:
Get only the total disk usage of a specific folder in bytes, useful for scripts.DISKUSE C:\Users\Admin /n /q
Common Issues
-
Permission Denied: If
DISKUSE
encounters directories which do not allow access, it may fail to report sizes correctly. Running CMD as an administrator can solve this issue. -
Incorrect Path: Users sometimes experience no output if the specified path does not exist. Double-check the entered path for correctness.
Integration
The DISKUSE
command can be integrated with other CMD commands for comprehensive disk management and scripting. For example:
FOR /D %p IN (C:\Users\*) DO @ECHO %p & DISKUSE %p /n /q
This script iterates over each user directory and reports its disk usage, ideal for audits or logs.
Related Commands
-
DIR
: Lists the files and folders in a directory, but without detailed size analysis. -
CHKDSK
: Checks the file system and file system metadata of a disk for logical and physical errors. -
XCOPY
: Copies files and directories, including directory structure and attributes, useful for backup tasks involving selected directories with significant size.
For further insights and elaborate use cases, the official Microsoft documentation on command-line tools provides extensive information and examples.