Introduction
Dropping into an unfamiliar codebase or auditing a project's folder layout is much easier with a visual map than with a scrolling file listing. CreateFileTree recursively walks a directory and prints it as a hierarchical, box-drawn tree diagram, showing every subdirectory and file at a glance — useful for documenting a project's structure, verifying a reorganization landed correctly, or just orienting yourself before touching unfamiliar code.
Teaching Note
Directory tree visualization is essential for:
- Documenting project structure in README files and documentation
- Understanding unfamiliar codebases and directory layouts
- Verifying correct file organization after restructuring
- Creating visual guides for onboarding new team members
- Debugging file path issues and missing directories
- Presenting project organization in reports and presentations
- Auditing directory contents and file placement
- Planning directory reorganization and cleanup efforts
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
pathrequired | | — | Absolute or relative path to the root directory to visualize. The function will recursively traverse all subdirectories starting from this location. |
indent_spaces | | 2 | Number of horizontal dash characters (─) to use for indentation at each level, controlling the visual spacing of the tree diagram. Defaults to 2. |
Returns
None — the function prints the directory tree diagram directly to stdout.
Example
python
from analysistoolbox.file_management import CreateFileTree
# Visualize a project directory with custom indentation
CreateFileTree(
path='/Users/username/projects/myapp',
indent_spaces=4
)
# Displays a directory tree with 4-dash indentation