English | 繁體中文
A PowerShell script tool for analyzing and visualizing directory structures and disk space usage.
This project is licensed under the MIT License - see the LICENSE file for details.
- Recursive analysis of directory structures and file sizes
- Customizable analysis depth
- Color-coded output for intuitive size visualization
- Automatic report generation and text file saving
- Smart sorting: prioritizes larger directories
- Automatic unit conversion support (GB, MB, KB, Bytes)
-
When executing the script, you'll be prompted to input:
- Target drive or path to analyze (e.g., C:)
- Directory depth to analyze (default is 2)
-
Analysis results will be:
- Displayed in real-time in the terminal
- Automatically saved to a text file on the desktop
- Red: Size greater than 1GB
- Yellow: Size greater than 100MB
- Cyan: Size less than 100MB
|--Documents [2.5 GB]
| |--Work [1.2 GB]
| |--Personal [800 MB]
The Get-DirectoryTreeWithSize function includes the following parameters:
Path: Target path to analyze (required)MaxDepth: Maximum analysis depth (default: 3)CurrentDepth: Current recursion depthIndent: Indentation stringOutputFile: Output file stream
-
Size Calculation:
- Recursive calculation of directory and subdirectory sizes
- Automatic unit conversion for appropriate display
-
Smart Filtering:
- Only processes directories larger than 10MB
- Optimizes performance by avoiding small directory analysis
-
Error Handling:
- Path existence verification
- File access permission handling
- Output file creation exception handling
-
Report Generation:
- Timestamp-based report filename generation
- UTF-8 encoding support
- Includes analysis time, path, and detailed information
- Sufficient permissions are required to access target paths
- Analysis of large directories may take considerable time
- Output files are automatically saved to the user's desktop
- Recommended to run from a PowerShell terminal with administrator privileges
- Windows Operating System
- PowerShell 5.0 or newer
- Execution policy must allow PowerShell script execution