Skip to content

basnijholt/clip-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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] 📚

🌟 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.

📚 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.

🛠️ 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.github.com/basnijholt/clip-files/main/clip_files.py

and run it using:

python clip_files.py --help

💡 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.

📁 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

🔢 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.

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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages