Skip to main content

Concatenate a directory full of files into a single prompt for use with LLMs

Project description

files-to-prompt

PyPI Changelog Tests License

Concatenate a directory full of files into a single prompt for use with LLMs

Installation

Install this tool using pip:

pip install files-to-prompt

Usage

To use files-to-prompt, provide the path to one or more files or directories you want to process:

files-to-prompt path/to/file_or_directory [path/to/another/file_or_directory ...]

This will output the contents of every file, with each file preceded by its relative path and separated by ---.

Options

  • --include-hidden: Include files and folders starting with . (hidden files and directories).

    files-to-prompt path/to/directory --include-hidden
    
  • --ignore-gitignore: Ignore .gitignore files and include all files.

    files-to-prompt path/to/directory --ignore-gitignore
    
  • --ignore <pattern>: Specify one or more patterns to ignore. Can be used multiple times.

    files-to-prompt path/to/directory --ignore "*.log" --ignore "temp*"
    

Example

Suppose you have a directory structure like this:

my_directory/
├── file1.txt
├── file2.txt
├── .hidden_file.txt
├── temp.log
└── subdirectory/
    └── file3.txt

Running files-to-prompt my_directory will output:

my_directory/file1.txt
---
Contents of file1.txt
---
my_directory/file2.txt
---
Contents of file2.txt
---
my_directory/subdirectory/file3.txt
---
Contents of file3.txt
---

If you run files-to-prompt my_directory --include-hidden, the output will also include .hidden_file.txt:

my_directory/.hidden_file.txt
---
Contents of .hidden_file.txt
---
...

If you run files-to-prompt my_directory --ignore "*.log", the output will exclude temp.log:

my_directory/file1.txt
---
Contents of file1.txt
---
my_directory/file2.txt
---
Contents of file2.txt
---
my_directory/subdirectory/file3.txt
---
Contents of file3.txt
---

Development

To contribute to this tool, first checkout the code. Then create a new virtual environment:

cd files-to-prompt
python -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

files-to-prompt-0.2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

files_to_prompt-0.2-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file files-to-prompt-0.2.tar.gz.

File metadata

  • Download URL: files-to-prompt-0.2.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.2

File hashes

Hashes for files-to-prompt-0.2.tar.gz
Algorithm Hash digest
SHA256 946fbaf556c1423f2dba0cfab457a4c7eae714041644c0315b258679406167ad
MD5 60211217702dfc8ede676ce0ae39dd00
BLAKE2b-256 66f51fe76b725e63f9fd4a3f91ccbdb07f958927626d231af6dbe7e937d90011

See more details on using hashes here.

File details

Details for the file files_to_prompt-0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for files_to_prompt-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7265dfbc8daf4080520d0ba7ba8273e6467818fd0a1d201362a72e2ecd4b01ca
MD5 11c4898a2358b64ab1071dd443a5e4c4
BLAKE2b-256 ea0b5f662376f8b213e8448276566d99356a8f19733955a65ebadbf3c86c0cdc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page