Skip to main content

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.
  • 📁 Surrounds each file with <file path="...">...</file> for easy parsing by LLMs.
  • 🧮 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] [-i INITIAL_FILE] [-f FILES [FILES ...]] [-m MAXDEPTH]
                  [folder] [extension ...]

Collect files with specific extensions or specific files, format them for clipboard, and count tokens.
There are two main ways to use clip-files:
1. Collecting all files with specific extensions in a folder:
   `clip-files FOLDER EXTENSION [EXTENSIONS ...]`
   Examples:
   - `clip-files . .py`  # all Python files in current directory
   - `clip-files . .py .md .txt`  # all Python, Markdown, and text files in current directory
   - `clip-files src .txt`  # all text files in src directory
   - `clip-files docs .md --initial-file instructions.txt`  # with custom instructions
2. Collecting specific files (can be of different types):
   `clip-files --files FILE [FILE ...]`
   Examples:
   - `clip-files --files src/*.py tests/*.py`  # using shell wildcards
   - `clip-files --files src/main.py docs/README.md`  # different file types
   - `clip-files -f src/*.py -i instructions.txt`  # with custom instructions

Options:
  -f, --files        Specify individual files to include
  -i, --initial-file A file containing initial instructions

Note: When using wildcards (e.g., *.py), your shell will expand them before passing to clip-files.

positional arguments:
  folder                The folder to search for files.
  extension             The file extensions to look for (e.g., .py, .txt). If
                        not provided, includes all non-hidden, non-binary
                        files.

options:
  -h, --help            show this help message and exit
  -i, --initial-file INITIAL_FILE
                        A file containing initial instructions to prepend to
                        the clipboard content. Default is an empty string.
  -f, --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 extensions are included.
  -m, --maxdepth MAXDEPTH
                        Maximum directory depth to traverse (default: no
                        limit)

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.

:bulb: Examples

[!TIP] Pro-tip! Just use uv to run clip-files without installing it. For example, uv run clip-files --files *.py will run clip-files in an temporary environment.

There are two main ways to use clip-files:

  1. Collecting all files with a specific extension in a folder:
# Collect all Python files in the current directory
clip-files . .py

# Collect all text files in the documents folder
clip-files documents .txt

# Collect all Python files, including custom initial instructions
clip-files src .py --initial-file instructions.txt
  1. Collecting specific files (can be of different types):
# Collect specific files
clip-files --files src/main.py tests/test_app.py

# Using shell wildcards to select files
clip-files --files src/*.py tests/*.py

# Mix different file types with wildcards
clip-files --files src/*.py docs/*.md config/*.json

# With custom initial instructions
clip-files --initial-file instructions.txt --files src/*.py

Note: When using wildcards (e.g., *.py), your shell will expand them before passing to clip-files.

: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

: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! 📋📁🎉

Metadata

Release files for clip-files 0.4.1

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

Source distribution (sdist)

Source distribution for clip-files 0.4.1
File Size Uploaded
clip_files-0.4.1.tar.gz 15.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for clip-files 0.4.1
File Interpreter ABI Platform
clip_files-0.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.5 kB

Release files / clip_files-0.4.1.tar.gz

Download URL clip_files-0.4.1.tar.gz
Size 15.7 kB
Tags Source
SHA-256 checksum
How to use checksums
98e3f714b598cc6fee70a9fcdb1b26a06ceddbf6e73b4b61734e199e7f04a3bf
BLAKE2b-256 checksum
How to use checksums
4e38bac62cf5dbc9860bb5e04443cbec06a2905432900cf9849e388c395458ce
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 Jan 29, 2026.

Transparency log

Release files / clip_files-0.4.1-py3-none-any.whl

Download URL clip_files-0.4.1-py3-none-any.whl
Size 11.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
061ba18bc4d86de737a67d9f4ab080adc8f5bfc620c324507f0ec2ebf63a22e8
BLAKE2b-256 checksum
How to use checksums
e169c8c6e896a3a8bd0c7bb5fa20c2b9abc9d4147412ee5111c4dd23e34605e0
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 Jan 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.1 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

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