Skip to main content

DTJ (Directory to JSON)

Overview

DTJ (Directory to JSON) is a Python command-line tool, particularly useful for quickly generating and sharing representations of directory structures in a token-efficient manner, making it ideal for interactions with language models like ChatGPT.

Example output

dtj
[
    {
        "filename": "main.py",
        "content": "# Main application file\nimport app\n\napp.run()"
    },
    {
        "filename": "app.py",
        "content": "# App module\n\ndef run():\n    print('Running the app')"
    },
    {
        "filename": "utils.py",
        "content": "# Utility functions\n\ndef helper():\n    return 'Helper function'"
    }
]

Features

  • Convert directory contents to JSON format.
  • Include or exclude specific file types.
  • Recursive directory parsing.
  • Options for output: printing to console, saving to a file, or copying to the clipboard.

Installation

pip install dtj

Usage

Run DTJ from the command line with the following options:

python dtj.py <target-directory> [options]

If no target directory is specified, DTJ will default to the current working directory.

Options:

  • -i or --include: Specify file extensions to include (e.g., py, html).
  • -e or --exclude: Specify file extensions to exclude.
  • -o or --output-file: Set the output JSON file name.
  • -r or --recursive: Enable recursive search in directories.
  • -p or --print: Print the output using rich formatting.
  • -c or --clipboard: Copy the output to the clipboard.

Example

python DTJ.py myfolder -i py html -o output.json -r

This command will parse all .py and .html files in myfolder recursively and save the JSON output to output.json.

Authors

  • Adrian Galilea - Initial work

Acknowledgments

  • Hat tip to ChatGPT for assistance with project setup and documentation.

Release files for dtj 0.1.2

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

Source distribution (sdist)

Source distribution for dtj 0.1.2
File Size Uploaded
dtj-0.1.2.tar.gz 3.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dtj 0.1.2
File Interpreter ABI Platform
dtj-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 8.3 kB

Release files / dtj-0.1.2.tar.gz

Download URL dtj-0.1.2.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
74db5854c936e14a5a26d9f8dd20442b734490bf3336bd69b9de6225c502d252
BLAKE2b-256 checksum
How to use checksums
aefc9d302ba6b3e39a1f2237c63387691944fb0734769cb5fc3708ea5707679d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release files / dtj-0.1.2-py3-none-any.whl

Download URL dtj-0.1.2-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bdd349e6c6da6a65721dcfe3555668a5bcba0b69e439ce24319dcabeb86b48e5
BLAKE2b-256 checksum
How to use checksums
f75da25fd14937907f2205d6c90a00aa12ba10c30a2e7a83436ff410313c386f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.3

Release history Release notifications | RSS feed

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

This release

0.1.2 This release

2 release files

0.1.1

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