Skip to main content

mktree

Create directory trees from a simple text specification. Quickly scaffold project structures, create nested directories, and generate files with comments—all from a single tree description.

Installation

pip install modularizer mktree

Quick Start

Command-Line Usage (recommended)

Just run mktree and you will get prompted to input the tree, or you can pass it in as the first arg

mktree

Python

from mktree import TreePath

if __name__ == "__main__":
    t = TreePath.from_tree("""
    my_project/
        src/
            my_project/
                __init__.py  # This
                __main__.py  # This runs when you call `python -m src.%my_project%`
                my_project.py
                cli.py
    """, my_project="soup").mktree()

Command-Line Options

  • --dst PATH: Set the root path for the tree (relabels the root)
  • --parent PATH: Wrap the tree in a parent directory
  • -y, --yes: Automatically use default path without prompting
  • --indent-size N: Set indentation size (default: 2)
  • --mode MODE: Set file permissions in octal (default: 777)
  • --no-parents: Don't create parent directories
  • --no-exist-ok: Don't ignore existing directories
  • NOTE: If neither --dst nor --parent is specified, mktree will prompt you for where to create the folder, showing a default based on the first root in your tree, unless you specify -y

From Command Line

mktree "my_project/
  src/
    __init__.py
  tests/
    test_main.py"

From File

mktree < tree.txt

Tree Specification Format

The tree specification supports multiple formats. mktree automatically detects the format based on the input:

Format 1: Indentation-Based (Default)

my_project/
  src/
    __init__.py
    main.py              # This comment will be written as a docstring at the top of main.py
  tests/
    __init__.py
    test_main.py         # Unit tests
  README.md              # Project documentation
  setup.py

Format 2: Unicode Box-Drawing Characters

├── my_project/
│   ├── src/
│   │   ├── __init__.py
│   │   └── main.py              # This comment will be written as a docstring at the top of main.py
│   └── tests/
│       ├── __init__.py
│       └── test_main.py         # Unit tests
├── README.md                     # Project documentation
└── setup.py

Format 3: ASCII Box-Drawing Characters

+-- my_project/
|   +-- src/
|   |   +-- __init__.py
|   |   \-- main.py
|   \-- tests/
|       \-- test_main.py
\-- README.md

Format 4: Prefix Markers

+ my_project/
+ src/
  - __init__.py
  - main.py              # Main entry point
+ tests/
  - __init__.py
  - test_main.py         # Unit tests
- README.md              # Project documentation
- setup.py

Format 5: JSON

{
  "my_project/": {
    "src/": {
      "__init__.py": null,
      "main.py": null
    },
    "tests/": {
      "__init__.py": null,
      "test_main.py": null
    },
    "README.md": null,
    "setup.py": null
  }
}

Format 6: Git ls-tree Format

Git tree format (like git ls-tree -r --name-only):

040000 tree my_project/
040000 tree my_project/src/
100644 blob my_project/src/__init__.py
100644 blob my_project/src/main.py
040000 tree my_project/tests/
100644 blob my_project/tests/__init__.py
100644 blob my_project/tests/test_main.py
100644 blob my_project/README.md
100644 blob my_project/setup.py

Note: mktree automatically detects the format based on the input. You can mix formats in different files, but each individual input should use a single format.

This creates:

my_project/
├── src/
│   ├── __init__.py
│   └── main.py
├── tests/
│   ├── __init__.py
│   └── test_main.py
├── README.md
└── setup.py

Examples

Example 1: Simple Project Structure

mktree "project/
  src/
    __init__.py
    app.py
  tests/
    test_app.py
  README.md"

Interactive Mode

Run without arguments to enter interactive mode:

$ mktree
Enter tree specification (end with Ctrl+D or empty line):
my_project/
  src/
    main.py
  tests/
    test_main.py
^D
Make at path: [./my_project] 
Created tree at: ./my_project

Requirements

  • Python 3.8 or higher
  • No external dependencies

License

Unlicense (Public Domain)

Contributing

Contributions welcome! Please feel free to submit issues or pull requests.

Metadata

Release files for modularizer-mktree 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modularizer-mktree 0.2.0
File Size Uploaded
modularizer_mktree-0.2.0.tar.gz 12.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for modularizer-mktree 0.2.0
File Interpreter ABI Platform
modularizer_mktree-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 24.3 kB

Release files / modularizer_mktree-0.2.0.tar.gz

Download URL modularizer_mktree-0.2.0.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b62b0e2fdc9fd8177c3264d1df23266e119e1e8ad67e4ddad3c37daf5d3bb13e
BLAKE2b-256 checksum
How to use checksums
8a9e319a9af157df42d3c6a094df0ba83aa36f2da9c1700ed7613f1b35a5bdcf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 9, 2025.

Transparency log

Release files / modularizer_mktree-0.2.0-py3-none-any.whl

Download URL modularizer_mktree-0.2.0-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7caab09a2cdc9b1e306f97d0b31ac16869bcb21658930c5c6bbf372042670593
BLAKE2b-256 checksum
How to use checksums
80001ea1077706f1ae85b7cd1f13e1f8a111b8d6ffcbf9ad1c393f86bb27762b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 9, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page