Skip to main content

clip-files copies.

Project description

Clip Files 📋📁

Build Coverage GitHub PyPI License Downloads Open Issues

Introducing clip-files - a simple yet useful command-line utility to gather files with a specific extension, format them with their full path, and copy their contents to your clipboard with a token count for GPT-4 usage! Makes it simple to paste in your entire project into e.g., ChatGPT or Claude.ai, now that massive token limits are available.

[ToC] 📚

:star2: Features

  • 📋 Collect files with a specific extension and copy their formatted contents to your clipboard.
  • 📁 Prepend each file with # File: full_path_here for clarity.
  • 🧮 Calculate and display the total number of tokens used, compatible with GPT-4 tokenization.
  • 🔄 Easily handle and process multiple files in various directories.

:books: Usage

To use clip-files, simply provide the directory to search and the file extension you want to collect:

clip-files --help

Shows the help message:

usage: clip-files [-h] [--initial-file INITIAL_FILE]
                  [--files FILES [FILES ...]]
                  [folder] [extension]

Collect files with a specific extension or specific files, format them for
clipboard, and count tokens.

positional arguments:
  folder                The folder to search for files.
  extension             The file extension to look for (e.g., .py, .txt).

options:
  -h, --help            show this help message and exit
  --initial-file INITIAL_FILE
                        A file containing initial instructions to prepend to
                        the clipboard content. Default is an empty string.
  --files FILES [FILES ...]
                        Specific file paths to include (e.g., --files
                        path/to/file1.py path/to/file2.md). If not provided,
                        all files with the specified extension are included.

clip-files will traverse the specified folder, gather files with the desired extension, format them with their paths, and copy the results to your clipboard along with the token count.

:hammer_and_wrench: Installation

To install clip-files, use pip:

pip install clip-files

Alternatively, clone the repository:

git clone https://github.com/basnijholt/clip-files.git
cd clip-files
pip install .

Or download the script directly:

wget https://raw.githubusercontent.com/basnijholt/clip-files/main/clip_files.py

and run it using:

python clip_files.py --help

:bulb: Examples

  • Collect all .py files in the src directory:
clip-files src .py
  • Collect .txt files in documents and count tokens:
clip-files documents .txt

For more examples and detailed usage instructions, refer to the documentation.

:file_folder: Supported File Types

clip-files supports any file type as long as you provide the correct file extension. Common examples include:

  • .py for Python files
  • .txt for text files
  • .md for Markdown files

:1234: Token Counting

clip-files integrates with the tiktoken library to calculate tokens as they would be counted in GPT-4. This helps in understanding the cost and feasibility of processing the collected text with GPT-4 models.

The script will display the total token count after copying the formatted content to the clipboard.

:heart: Support and Contributions

We welcome feedback and contributions! If you encounter any issues or have suggestions for improvements, please file an issue on our GitHub repository. Contributions via pull requests are also appreciated.

Happy collecting and clipping! 📋📁🎉

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

clip_files-0.1.0.tar.gz (11.6 kB view hashes)

Uploaded Source

Built Distribution

clip_files-0.1.0-py3-none-any.whl (10.0 kB view hashes)

Uploaded Python 3

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