Convert ChatGPT/LLM-style folder tree text to real files and folders
Project description
tree2cmd
Convert tree-style directory text into shell commands (mkdir and touch).
Installation
pip install tree2cmd
Features
- Parse tree-like folder structures from text files or standard input
- Support emojis and common tree characters (
├──,│,└──, etc.) - Heuristically detect folders vs. files (folder if ends with
/or indentation implies children) - Generate safe shell commands:
mkdir -pfor directories,touchfor files - Optionally execute commands or save them into a shell script
- Handle indentation-based nesting with configurable indent width (default: 2 spaces)
- Properly escape special shell characters inside quotes
- Lightweight and dependency-free, compatible with Python 3.7+
Usage
Run tree2cmd from the command line:
-
Dry-run (print commands):
tree2cmd <input_file> -
Execute commands to create files and folders:
tree2cmd <input_file> --run
-
Save generated commands to a shell script:
tree2cmd <input_file> --save <script.sh>
-
Read input from standard input:
cat structure.txt | tree2cmd --stdin
Adjust indentation width with --indent-width if your input uses non-standard spacing.
FAQ & Troubleshooting
-
Does this work on Windows CMD or PowerShell?
Generated commands target bash shells (Linux/macOS/WSL). Windows native shells are not supported. -
Special characters cause errors?
Input paths are quoted and escaped, but ensure input format is clean and consistent. -
Indentation detection issues?
Verify your input uses consistent indentation and set--indent-widthaccordingly.
Contributing
Contributions are welcome! To contribute:
-
Fork the repository
-
Clone it locally
-
Run tests:
python -m unittest discover tests
-
Implement your changes and commit
-
Push and open a Pull Request
Ideas for future enhancements: Windows shell support, custom file templates, GUI frontend.
Disclaimer
Experimental project — use at your own risk. Always review generated commands before execution. No liability for data loss.
Author
AnJoMa — antonyjosephmathew1@gmail.com
GitHub: https://github.com/ajmanjoma/tree2cmd
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tree2cmd-0.1.2.tar.gz.
File metadata
- Download URL: tree2cmd-0.1.2.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a46b5da94f338f8d376ebc005d3db0604c27cb65717877e00748db7bdf81877
|
|
| MD5 |
19b4414d5f7c715ccd3e2eaa20c28342
|
|
| BLAKE2b-256 |
227e0491c4abca94aea64a2cad4fc91f3eecd58388728065bc5c77ff86d4d368
|
File details
Details for the file tree2cmd-0.1.2-py3-none-any.whl.
File metadata
- Download URL: tree2cmd-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33e7b7661bc7418cf768e2577af15effc79e6862bb9432a90ba092715eb18ebc
|
|
| MD5 |
bdffb30827eac1933def32d5abdc7fb0
|
|
| BLAKE2b-256 |
c81b50826c2d05ce539f8ecb5f0ac1c7ffd8a84c8dda84b438160e513a49ee38
|