A Python script to display a colorful, organized tree view of any folder in your terminal — complete with icons, depth-based coloring, file-type highlighting, and a summary report.
- 🎨 Beautiful colored output using Rich
- 📁 Root folder highlighted in pink (
#FE83F8) - 🌳 Depth-based coloring for folders (same level = same color)
- 📄 File-type based coloring (code, docs, media, logs, etc.)
- 📑 Optional folder & file icons — toggle with
SHOW_ICONS - 🚫 Permission error handling
- 🖱️ Simple GUI folder picker (via
tkinter) - 📊 Summary section after tree view:
- Total folders
- Total files
- Total items
- Total size (bytes + human-readable)
You can customize the script’s behavior by editing the variables in the code:
| Variable | Type | Description |
|---|---|---|
SHOW_ICONS |
bool | Toggle file/folder icons (True or False) |
ROOT_COLOR |
str | Hex or Rich-compatible color for the root folder |
DEPTH_COLORS |
list | Colors for folder levels (cycled per depth) |
FILE_TYPE_COLORS |
dict | Mapping of file extensions to colors |
# Clone this repo or copy the script
git clone https://github.com/yourusername/folder-tree-viewer.git
# Install dependencies
pip install rich
Note: tkinter is included in most Python installations.
On some Linux distros, you may need to install it via your package manager.python folder_tree_viewer.pyEdit the DEPTH_COLORS list to define colors for different levels:
DEPTH_COLORS = ["cyan", "green", "yellow", "magenta", "blue"]You can map file extensions to specific colors:
FILE_TYPE_COLORS = {
".py": "bright_green",
".txt": "yellow",
".md": "cyan",
".json": "magenta",
".log": "red",
}The root folder color can be changed via:
ROOT_COLOR = "#FE83F8"Change root folder color:
ROOT_COLOR = "#FE83F8"Disable icons for a simpler text-only output:
SHOW_ICONS = FalseAt the end of the output, you will see:
📁 MyProjects
├── 📂 Scripts
│ ├── 📄 script1.py
│ └── 📄 script2.sh
└── 📂 Docs
├── 📄 notes.txt
└── 📄 guide.pdf
Summary:
📂 3 folders
📄 4 files
📦 Total items: 7
💾 Total size: 12.34 MB (12942384 bytes)
License: MIT © 2025 Harikalatheeswaran
See LICENSE file for details.