python_treeLsCat is a lightweight Python utility designed to crawl a project directory, generate a visual folder structure (tree), and consolidate the content of all text-based files into a single output file.
It is specifically built to respect .gitignore rules and automatically skip binary files, making it perfect for preparing codebases for LLM analysis (ChatGPT/Claude) or quick code audits.
- Smart Tree Generation: Creates an alphabetical directory tree.
- Full Gitignore Support: Automatically reads your project's
.gitignoreand skips hidden/ignored files (e.g.,node_modules,bin/,obj/). - Binary Protection: Intelligently detects and skips binary files (
.dll,.exe,.png, etc.) using null-byte detection. - Safe Saving: Never overwrites files; it adds a numeric suffix (e.g.,
output_1.txt) if the file already exists. - Auto-Configuration: Generates a
config.inion the first run if one isn't found. - Detailed Logging: Provides timestamps and debug info for every action.
- Clone the repository:
Install dependencies: This tool requires the pathspec library:
git clone git@github.com:mamba73/python_treeLsCat.git cd python_treeLsCatpip install pathspec
- Run the script:
python python_treeLsCat.py
- Configure:
On the first run, a config.ini will be created. Set your project path:
[SETTINGS] PATH = C:\Path\To\Your\Project SAVE = project_summary.txt
- Check Output: The result will be stored in the ./save (sub)directory of python_treeLsCat.
The generated file will look like this:
PROJECT STRUCTURE: MyProject
------------------------------
ββ src/
β ββ main.py
β ββ utils.py
ββ .gitignore
ββ README.md
============================================================
src/main.py
---
[File Content Here]
---
---
README.md
---
[File Content Here]
---
---
This project is open-source and available under the MIT License.
Developed by mamba73. Feel free to submit issues or pull requests!