A simple utility to prepare files for AI analysis by copying them with their directory structure encoded in the filename.
aixtract
reads a list of file paths from a .aixtract
file and copies each file to a new directory, encoding the original path hierarchy into the filename using double underscores (__
).
For example, src/models/user.py
becomes src__models__user.py
.
This is particularly useful when preparing files to upload to AI assistants that don't support directory structures.
pip install aixtract
- Create a
.aixtract
file in your project directory listing the files you want to process:
src/models/user.py
tests/test_user.py
config/settings.json
# Lines starting with # are ignored
- Run the command:
aixtract
The utility will:
- Create a new directory in your Downloads folder named
project_name_YYYYMMDD_HHMMSS
- Copy each listed file to this directory, converting path separators to double underscores
- Preserve file permissions and metadata
- Open the target directory automatically (on supported platforms)
If your project structure looks like this:
myproject/
├── .aixtract
├── src/
│ └── models/
│ └── user.py
├── tests/
│ └── test_user.py
└── config/
└── settings.json
And your .aixtract
contains:
src/models/user.py
tests/test_user.py
config/settings.json
Running aixtract
will create:
/tmp/myproject_20250101_123456/
├── src__models__user.py
├── tests__test_user.py
└── config__settings.json
The utility will:
- Skip files that don't exist with a warning
- Skip empty lines and comments in
.aixtract
- Exit with error if
.aixtract
file is not found - Show clear error messages for any issues during copying
- Python 3.8 or later
- Works on macOS, Linux, and Windows (directory opening feature supported on macOS and Linux)