ListTopLevelDirectorySizes is a PowerShell script that calculates and displays the sizes of immediate subdirectories in a given path. It provides a quick and easy way to understand space usage across top-level folders in a specified directory.
- Recursively calculates the size of each subdirectory
- Displays only top-level directory sizes
- Sorts directories by size in descending order
- Provides a total size of all directories
- Easy-to-use command-line interface
- PowerShell V3 or higher
- Clone this repository or download the
ListTopLevelDirectorySizes.ps1
file. - Ensure you have PowerShell V3 or higher installed on your system.
Run the script from PowerShell, providing the target path as an argument:
.\ListTopLevelDirectorySizes.ps1 -targetPath "C:\Path\To\Your\Directory"
-
Analyze the Documents folder:
.\ListTopLevelDirectorySizes.ps1 -targetPath "C:\Users\YourUsername\Documents"
-
Analyze a Projects folder on the D drive:
.\ListTopLevelDirectorySizes.ps1 -targetPath "D:\Projects"
The script will output a list of directories sorted by size in descending order, followed by the total size of all directories. For example:
1500.50 MB C:\Users\YourUsername\Documents\LargeFolder
750.25 MB C:\Users\YourUsername\Documents\MediumFolder
250.75 MB C:\Users\YourUsername\Documents\SmallFolder
Total size of all directories: 2.44 GB
To view the help information and usage examples, run:
Get-Help .\ListTopLevelDirectorySizes.ps1
This project is licensed under the MIT License.
JENISH RUDANI
1.0
Contributions are welcome! Please feel free to submit a Pull Request.