Skip to main content

A tool to combine multiple files while preserving directory structure

Project description

FileCombinator

PyPI version Build Status Coverage License Python Versions

FileCombinator is a Python tool that creates a comprehensive, single-file representation of your codebase, optimized for AI analysis. It preserves directory structure and file content while handling binary files intelligently, making it perfect for sharing your codebase with AI assistants.

Features

  • Creates AI-friendly single-file codebase representation
  • Preserves directory structure and file relationships
  • Includes source code with proper encoding
  • Handles binary/image files by including metadata only
  • Configurable file and directory exclusions
  • Rich terminal output with progress indication

Installation

pip install filecombinator

Usage

Basic usage:

filecombinator                    # Process current directory
filecombinator -d /path/to/dir    # Process specific directory
filecombinator -o output.txt      # Custom output file
filecombinator -e node_modules    # Exclude patterns
filecombinator -v                 # Verbose output

File Handling

FileCombinator handles files in three different ways:

  1. Regular Files - Full content included:

    • Source code files
    • Text files
    • Configuration files
    • Documentation
  2. Binary/Image Files - Included with metadata only:

    • Binary files (executables, compiled files)
    • Image files (.jpg, .png, .gif, etc.)
    • These files appear in the output but their content is omitted
  3. Excluded Files/Directories - Completely skipped:

    • Cache directories (__pycache__, .cache)
    • Virtual environments (.venv, env)
    • Version control (.git)
    • Build artifacts (dist, build)
    • Any patterns specified with -e flag

Output Format

The tool creates a structured output file containing:

# Directory structure
├── src
│   ├── main.py
│   └── utils.py
└── assets
    └── logo.png

# Text files - full content
================== FILE SEPARATOR ==================
FILEPATH: src/main.py
Metadata: Type: Text, Size: 1234 bytes, Last Modified: 2024-11-12 18:31:15
[Full file content included]

# Binary/Image files - metadata included, content omitted
================== FILE SEPARATOR ==================
FILEPATH: assets/logo.png
Metadata: Type: Image, Size: 45678 bytes, Last Modified: 2024-11-12 18:31:15
[Content excluded]

# Excluded files/directories - not included in output at all
.git/, .venv/, __pycache__/, etc.

Configuration

Configuration files can be placed in (in order of priority):

  1. Project: ./filecombinator.yaml or ./.filecombinator.yaml
  2. User: ~/.config/filecombinator/config.yaml (Unix) or %APPDATA%\filecombinator\config.yaml (Windows)
  3. System: /etc/filecombinator/config.yaml (Unix)

Example configuration:

exclude_patterns:
  - "__pycache__"
  - ".venv"
  - "node_modules"

logging:
  default_log_file: "logs/file_combinator.log"
  default_level: "INFO"

output:
  file_suffix: "_file_combinator_output.md"

Development

git clone https://github.com/your-username/filecombinator.git
cd filecombinator
make venv                 # Create the virtual environment
source .venv/bin/activate # Activate the virtual environment
make install              # Install dependencies
make test                 # Run tests
make lint                 # Run linting

License

MIT License - see LICENSE file.

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

filecombinator-0.4.0.tar.gz (36.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

filecombinator-0.4.0-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file filecombinator-0.4.0.tar.gz.

File metadata

  • Download URL: filecombinator-0.4.0.tar.gz
  • Upload date:
  • Size: 36.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.10

File hashes

Hashes for filecombinator-0.4.0.tar.gz
Algorithm Hash digest
SHA256 0ecf1c4ddd2a52402961fe99fa5fff172c710ac6d4b571fdfa6aef507505d2da
MD5 235446b9a59a146bfd9bcb0964d3a51b
BLAKE2b-256 401f463c374cce0879de12f363ddde0e684645293015f538e8643eb487337e52

See more details on using hashes here.

File details

Details for the file filecombinator-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: filecombinator-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.10

File hashes

Hashes for filecombinator-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbafa2f6b0bc7aca693b621058c24286916b042bd910509216b2cfffd4abeab5
MD5 4ca58df69bd91688a300154b0d9fc4a5
BLAKE2b-256 2d28ff735d8b2b1c07be5af238bc4b08f6d9abb96631ce89a81d87f48cfa6b3d

See more details on using hashes here.

Supported by

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