Parse a visual tree diagram – create all folders and empty files instantly.
Perfect for scaffolding projects fromtreeoutput, documentation mockups, or your own ASCII/Unicode art.
- 📁 Creates full directory hierarchies – from a simple text tree
- 📄 Generates empty files (like
touch) with parent directories - 🧹 Ignores inline comments – anything inside
( )is stripped - 🧠 Smart parsing – handles
├──,└──,│, and spaces - 🚫 Optional exclusion – skip build dirs like
target/(one line to uncomment) - 🧪 Zero dependencies – uses only Python standard library
- 💻 Cross‑platform – Linux, macOS, Windows (WSL / Git Bash)
# 1. Get the script
curl -O https://raw.githubusercontent.com/yourname/tree_setup/main/tree_setup.py
chmod +x tree_setup.py
# 2. Pipe your tree directly into it
./tree_setup.py <<'EOF'
my-project/
├── src/
│ ├── main.rs
│ └── lib.rs
├── Cargo.toml
└── README.md
EOFResult: the exact tree structure appears on your disk, ready to be filled with code.
./tree_setup.py [tree-file]| Mode | Command |
|---|---|
| From a file | ./tree_setup.py project_tree.txt |
| From stdin (pipe) | cat tree.txt | ./tree_setup.py |
| From heredoc | ./tree_setup.py <<'EOF' ... EOF |
The script accepts any tree that uses these characters:
├── (middle child)
└── (last child)
│ (vertical line for indentation)
(4 spaces also work)
bedepacko/ (root directory)
├── bede.sh (thin wrapper script)
├── bede-engine/ (Rust project)
│ ├── Cargo.toml
│ ├── src/ (source folder)
│ │ ├── main.rs
│ │ ├── downloader.rs
│ │ ├── resolver.rs
│ │ ├── manifest.rs
│ │ └── lockfile.rs
│ └── target/ (build output – optional)
💡 Tip: You can copy-paste the output of the
treecommand directly – comments are optional but very handy for documentation.
Inside tree_setup.py, uncomment this line:
# entries = [(p, d) for p, d in entries if not p.startswith('target')]Modify the create_from_entries function. For example, to add fn main() {} to every main.rs:
if full.name == "main.rs":
full.write_text('fn main() {\n println!("Hello");\n}\n')Input (rust-tree.txt):
my_crate/
├── Cargo.toml
├── src/
│ ├── main.rs
│ ├── lib.rs
│ └── bin/
│ └── tool.rs
├── tests/
│ └── integration.rs
└── examples/
└── demo.rs
Command:
./tree_setup.py rust-tree.txtOutput on disk:
my_crate/
├── Cargo.toml
├── src/
│ ├── main.rs
│ ├── lib.rs
│ └── bin/
│ └── tool.rs
├── tests/
│ └── integration.rs
└── examples/
└── demo.rs
All files are empty (0 bytes) – ready for you to write code.
- ✅ Existing files are never overwritten (
touchusesexist_ok=True). - ✅ Trailing slashes (
src/) → directory. No trailing slash → file. - ✅ The first line (root directory) is also created.
- ❌ The script does not write any content by default – only empty placeholders.
- Python 3.6+ (any modern Python)
- No third‑party packages – pure standard library.
Issues, feature requests, and pull requests are very welcome!
If you need support for ASCII trees (|--, `--) or other edge cases, please open a ticket.
MIT – use freely, modify as you like. Attribution appreciated but not required.
Inspired by developers who love visual project planning and hate manual mkdir & touch marathons.
Happy scaffolding! 🌲✨