A tiny script that turns a text tree into real folders and files β demonstrated on the most important project of all: counting sheep before bed.
create_structure.py reads a plain-text folder tree (the kind tree outputs,
or the kind you'd sketch by hand) and builds the real folders and files from
it, right in your project root.
python create_structure.py structure.txt .It understands both common tree styles:
Unicode (βββ, βββ, β) β what you get from tree on Linux/macOS,
or what most people type by hand:
project/
βββ src/
β βββ main.py
β βββ utils/
β βββ helpers.py
βββ tests/
β βββ test_main.py
βββ requirements.txt
βββ README.md
Windows ASCII (+---, \---, |) β the output of tree /F on Windows:
+---src
| | main.py
| |
| \---utils
| helpers.py
+---tests
| test_main.py
|
| requirements.txt
\---README.md
Both formats work as-is β no need to convert one into the other, just point the script at whichever one you've got.
It figures out files vs. folders automatically (trailing /, or by checking
whether anything is nested underneath), and it's idempotent β rerun it and it
won't clobber files that already exist.
structure.txt in this repo is just an example input β
a made-up project structure for a fictional app that counts sheep before you
fall asleep (flock/, sleep/, a dream_log.json, the works). It's not a
real project; it's here purely to show the script working on something more
fun than src/, tests/, README.md.
Swap it out for your own structure.txt and it'll scaffold your project
instead β that's the whole point.
# try the demo
python create_structure.py structure.txt ./demo-output
# use it for real
python create_structure.py my-project-structure.txt .python create_structure.py <structure_file> [target_dir]
| Argument | Description |
|---|---|
structure_file |
Path to a text file describing the tree |
target_dir |
Where to build it (defaults to current directory) |
| File | Purpose |
|---|---|
create_structure.py |
The actual tool |
structure.txt |
Example/demo input (the sheep-counting project π) |
README.md |
This file |
MIT β see LICENSE.