clip-files copies.
Project description
Clip Files 📋📁
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
uvto runclip-fileswithout installing it. For example,uv run clip-files --files *.pywill runclip-filesin an temporary environment.
There are two main ways to use clip-files:
- 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
- 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:
.pyfor Python files.txtfor text files.mdfor 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file clip_files-0.4.1.tar.gz.
File metadata
- Download URL: clip_files-0.4.1.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98e3f714b598cc6fee70a9fcdb1b26a06ceddbf6e73b4b61734e199e7f04a3bf
|
|
| MD5 |
c6b4b7e16e8dd9fc15785c5c81d1f9c0
|
|
| BLAKE2b-256 |
4e38bac62cf5dbc9860bb5e04443cbec06a2905432900cf9849e388c395458ce
|
Provenance
The following attestation bundles were made for clip_files-0.4.1.tar.gz:
Publisher:
release.yml on basnijholt/clip-files
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clip_files-0.4.1.tar.gz -
Subject digest:
98e3f714b598cc6fee70a9fcdb1b26a06ceddbf6e73b4b61734e199e7f04a3bf - Sigstore transparency entry: 871107347
- Sigstore integration time:
-
Permalink:
basnijholt/clip-files@92e0542c7faa3d09df97f0c0e881aa7b40b1084e -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/basnijholt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@92e0542c7faa3d09df97f0c0e881aa7b40b1084e -
Trigger Event:
release
-
Statement type:
File details
Details for the file clip_files-0.4.1-py3-none-any.whl.
File metadata
- Download URL: clip_files-0.4.1-py3-none-any.whl
- Upload date:
- Size: 11.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
061ba18bc4d86de737a67d9f4ab080adc8f5bfc620c324507f0ec2ebf63a22e8
|
|
| MD5 |
01f1aeb9cdb73363e5dfc3985e042983
|
|
| BLAKE2b-256 |
e169c8c6e896a3a8bd0c7bb5fa20c2b9abc9d4147412ee5111c4dd23e34605e0
|
Provenance
The following attestation bundles were made for clip_files-0.4.1-py3-none-any.whl:
Publisher:
release.yml on basnijholt/clip-files
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
clip_files-0.4.1-py3-none-any.whl -
Subject digest:
061ba18bc4d86de737a67d9f4ab080adc8f5bfc620c324507f0ec2ebf63a22e8 - Sigstore transparency entry: 871107386
- Sigstore integration time:
-
Permalink:
basnijholt/clip-files@92e0542c7faa3d09df97f0c0e881aa7b40b1084e -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/basnijholt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@92e0542c7faa3d09df97f0c0e881aa7b40b1084e -
Trigger Event:
release
-
Statement type: