This small Python utility reads a tree-like text description (e.g., structure.txt) and creates the corresponding folders and files on disk. It's useful for bootstrapping a project skeleton from a plain text outline.
create_structure.py— main script that parses the structure file and creates folders/files.structure.txt— example input showing a tree using box-drawing characters and/for folders.
- Python 3.7+ (tested on 3.8+)
- No external packages required (uses the standard library)
-
Open a terminal in the repository folder.
-
Run:
python create_structure.py
-
When prompted, enter the structure file name, for example:
Enter the structure file (e.g., structure.txt): structure.txt
The script will parse the file and create directories and files under the current working directory. It prints created items like [DIR ] and [FILE] lines.
- Lines that end with
/are treated as directories. - Box-drawing characters such as
│ ├ └ ─(and emojis like📁 📄) are supported and removed during parsing. - Blank lines are ignored.
- The parser uses the prefix to determine depth; indentation may be box characters or groups of spaces.
- The script will create files and directories—test it in an empty folder or a temporary directory first.
- Add a
--dry-runor command-line argument option to avoid interactive input. - Add a
--rootflag to change the destination base.
You may use or adapt this script freely. Consider adding an explicit license (e.g., MIT) to the repo.
Welcome! If you want, I can also add a README.md (Markdown) version optimized for GitHub display or implement command-line options for convenience.