Python · Developer Tooling
Generate a Clean Folder Tree of Any Project with Python
Run list_structure.py on a project and it writes FolderFileStructure.txt: a tree with branch connectors, directories first, noise folders excluded, and a file count summary.
PythonargparseRecursive DFS
Abstract
The problem
Explaining the architecture of a nested project through a file explorer is hard, and hand-formatting tree structures for documentation is slow and error-prone.
The solution
A CLI tool that walks a root directory with recursive depth-first search, skips noise folders and draws a connector-style tree.
The result
A professional FolderFileStructure.txt that maps any codebase in seconds.
Input & Output
Input
- Root folder (current directory by default, or --root path)
- Optional --exclude rules
Output
- FolderFileStructure.txt at the root
Optional output
- Timestamped header and absolute root path
- Final count of directories and files processed
System Diagram
CLI / argparse
--root · --exclude
DFS walk
Recursive traversal
Exclusion engine
20+ default junk names
Tree renderer
├── └── │ connectors
FolderFileStructure.txt
Tree + summary
How It Works
Intelligent exclusions
Ignores .git, node_modules, .venv, __pycache__, .DS_Store and 20+ more.
Recursive visualisation
A walk function draws a readable branch hierarchy.
Smart sorting
Directories first, case-insensitive order for consistent output.
CLI flexibility
Override the root or add custom exclusions from the command line.
Configuration
| Option | Purpose |
|---|---|
DEFAULT_EXCLUDES | Pre-set for Python, JavaScript and Flutter projects. |
--root | Project folder to map. |
--exclude | Repeatable flag to add extra ignored names. |
How to Run
python list_structure.pypython list_structure.py --root "C:/Path/To/Your/Project"python list_structure.py --exclude "temp_logs" --exclude "secrets"Impact & Benefits
Screenshots
Frequently Asked Questions
How do I print a folder structure as a tree in Python?
The script walks the directory recursively (depth-first) and draws branch connectors, writing the result to FolderFileStructure.txt.
Which folders does it ignore?
More than 20 defaults such as .git, node_modules, .venv, __pycache__ and .DS_Store. Add more with repeated --exclude flags.
Is the output useful for AI coding assistants?
Yes. A compact project map gives tools like ChatGPT or Claude the architecture context in one paste.
Related
Create a Whole Project Folder Structure from a Python Dictionary
Deploys a whole Clean-Architecture folder tree from a single Python dictionary in milliseconds.
Read documentationList Every File in a Folder to a Text or CSV Manifest with Python
Crawls a folder and produces a clean, copy-ready manifest of file names, types and sizes.
Read documentation
