Displays the sizes of subfolders in a directory. Copyright (C) 2026 by Russ Le Blang
This was created solely with Github Copilot and prompting. No user intervention within the code itself. This is my example of "Results Driven Development". Prompting continued until the expected behavior was obtained.
FOLDERSIZES [--SORT name|size] [--PATH folder] [--DEPTH n] [--CSV=file] [--JSON=file] [--BYTES]
| Option | Description |
|---|---|
--HELP |
Displays this help message. |
--SORT name|size |
Sorts output by folder name or size. Default is name. |
--PATH folder |
Specifies the folder to scan. Default is the current directory. |
--DEPTH n |
Limits recursion depth. Default is unlimited. |
--CSV=file |
Exports results to a CSV file. |
--JSON=file |
Exports results to a JSON file. |
--BYTES |
Shows sizes in raw bytes instead of human-readable format. |
FolderSizes supports convenient shorthand notation:
nameorsize- Can be used without--SORTprefix (e.g.,foldersizes size)folder path- Can be used without--PATHprefix (e.g.,foldersizes C:\Data)- Combine both -
foldersizes size C:\Data
# Display subfolders in current directory, sorted by name
foldersizes
# Sort by size (largest first)
foldersizes size
# Scan a specific directory
foldersizes C:\Data
# Combine sort and path
foldersizes size "E:\PC\PC Games"
# Using explicit flags
foldersizes --SORT size
foldersizes --PATH "E:\PC\PC Games"
# Limit recursion depth to 1 level
foldersizes --DEPTH 1
# Export results to CSV
foldersizes --CSV=output.csv
# Display sizes in raw bytes
foldersizes --BYTES
# Show help
foldersizes --HELP- Human-readable sizes - Automatically converts bytes to KB, MB, GB, TB
- Raw byte display - Use
--BYTESflag for precise byte counts - Summary statistics - Shows total size, folder count, and average folder size
- Multiple sort options - Sort by name or size
- Export formats - CSV and JSON export capabilities
- Recursion control - Limit folder depth scanning
- Fast performance - Parallel processing on PowerShell 7+
- PS5.x compatible - Falls back to sequential processing on PowerShell 5.x
Folder Name Total Size
---------------------------
backup 393.14 KB
resources 171.00 KB
---------------------------
Total: 564.13 KB
Folders: 2 | Average: 282.07 KB
- PowerShell 5.1 or higher
- Visual C++ redistributable (for executable version)
To compile the PowerShell script into an executable:
.\make.batThis creates foldersizes.exe with an embedded icon using PS2EXE.