A Python script that displays disk usage in a hierarchical tree view with colored visualization of space consumption.
- Tree view of directory structure
- Color-coded sizes and usage bars
- Size-based filtering
- Configurable depth level
- Sorting by size (largest first)
- Space usage visualization relative to parent directory
- Disk usage summary
- Download the script:
wget https://raw.githubusercontent.com/Tomtomcapo/dstree/refs/heads/main/dstree.py
- Make it executable:
chmod +x dstree.py
- Optionally, move it to your PATH:
sudo mv dstree.py /usr/local/bin/dstree
Basic usage:
./dstree.py <directory_path>
With options:
./dstree.py <directory_path> --depth <number> --threshold <size_in_GB>
--depth
: Maximum depth to analyze (default: unlimited)--threshold
: Minimum size threshold in GB (default: 0.2)
./dstree.py /home/user --depth 2 --threshold 1
Disk Usage: 145.7GB/163.7GB (89.0%)
Free Space: 9.7GB
███████████████████████████████████░░░░░ 89.0%
/ (111.6GB)
├──folder1/ (29.5GB) ███████░░░░░░░░░░░░░░░░░░░░░░░ 26.4%
│ ├──subfolder/ (11.5GB) ███████████░░░░░░░░░░░░░░░░░░░ 39.0%
│ └──file.dat ( 1.2GB) █░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ 4.1%
│
└──folder2/ (15.8GB) ████░░░░░░░░░░░░░░░░░░░░░░░░░░ 14.2%
Sizes:
- 🟢 < 100MB
- 🟡 100MB-500MB
- 🟠 500MB-1GB
- 🔴 > 1GB
Usage bars:
- 🟢 < 60% usage
- 🟡 60-85% usage
- 🔴 > 85% usage
- Python 3.6+
- No external dependencies
MIT License
Feel free to open issues and pull requests!