Skip to main content

touch-struct

A tool to create directory and file structures from text representations like the ones you might get from ChatGPT.

Installation

You can install via pip:

pip install touch-struct

Usage

touch-struct can be used both as a command-line tool and as a Python library.

Command Line Usage

The most convenient (but maybe not obvious) way to use touch-struct may be to paste the structure directly into your terminal like this:

  1. Copy the structure you want to create into your clipboard. (Usually from ChatGPT or similar)
  2. In your terminal, go to the directory you want to create the structure in.
  3. Type touch-struct - (the dash is important!) and hit enter.
  4. Paste the structure into the terminal.
  5. Press Ctrl+D (which means "end of file") to finish.
  6. Voila! The structure is created!

There are however a few other ways to use it:

# Create from a file
touch-struct structure.txt

# Create in a specific directory
touch-struct structure.txt --output-dir my-new-project

# Create from stdin (pipe)
cat structure.txt | touch-struct -

Python Library Usage

import touch_struct

# Create from a string
structure = """
project/
├── src/
│   ├── main.py
│   └── utils.py
├── tests/
│   └── test_main.py
├── README.md
└── setup.py
"""
touch_struct.from_string(structure)

# Create from a file
touch_struct.from_file("structure.txt")

# Create in a specific directory
touch_struct.from_string(structure, base_path="my-new-project")
touch_struct.from_file("structure.txt", base_path="my-new-project")

Structure Format

The tool accepts a text representation of directory structures using ASCII characters:

  • Use / at the end of a line to indicate directories
  • Use standard ASCII characters (, , , ) to draw the tree structure
  • Indentation and structure characters are used to determine hierarchy

Example structure file:

my-project/
├── src/
│   ├── main.py
│   └── utils.py
├── tests/
│   └── test_main.py
└── docs/
    ├── index.md
    └── api.md

You can also create multiple root directories or files:

README.md
LICENSE
frontend/
├── src/
│   └── app.js
└── package.json
backend/
├── src/
│   └── server.py
└── requirements.txt

Tips

  • Files shouldn't have a trailing slash: README.md
  • Directories need a trailing slash: src/
  • Spaces in names are supported: My Project/
  • You can mix files and directories at any level
  • The structure can be as deep as you need
  • Root level can contain multiple files and directories

Contributing

For detailed information about contributing, including how to make releases, please see CONTRIBUTING.md.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Release files for touch-struct 0.1.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 touch-struct 0.1.0
File Size Uploaded
touch_struct-0.1.0.tar.gz 9.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for touch-struct 0.1.0
File Interpreter ABI Platform
touch_struct-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / touch_struct-0.1.0.tar.gz

Download URL touch_struct-0.1.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
a9b2e06e524135acb682a960da83b52c3ef3310e6faab551c4f8498a024e5010
BLAKE2b-256 checksum
How to use checksums
18d12c193967af8c28ad8ad8216fa61d59f00fd5514b604a8305beeb4a60ed50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / touch_struct-0.1.0-py3-none-any.whl

Download URL touch_struct-0.1.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50949b62f42687f8ae7e561128337fbea1b1e06d1cf8de302d0ce6e89b5f1679
BLAKE2b-256 checksum
How to use checksums
43c629c68da3c63742aef81f27db5067cf8ce00bb40e24cc0e8bed9060b0aa16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

0.1.0 This release

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