A Python package for organizing and renaming files using AI.
git clone https://github.com/amacinho/fileai.git
cd fileai
pip install .
export GEMINI_API_KEY=<ADD YOUR GEMINI API KEY>
# Check for duplicate files in documents folder (using SHA256 hash of the content)
fileai-dedupe --dry-run ~/tmp/documents
# Actually dedupe files
fileai-dedupe ~/tmp/documents
# Categorize files in documents folder
fileai-process ~/tmp/documents ~/tmp/output gemini
# fileai will start processing ~/tmp/documents for new files and categorize them under ~/tmp/output.FileAI requires a Gemini API key to function. You can provide your API key in one of three ways:
-
Environment Variable
export GEMINI_API_KEY=your-api-key -
Configuration File Create a JSON configuration file at
~/.fileai/config.json(Linux/Mac) or%APPDATA%\fileai\config.json(Windows):{ "api_key": "your-api-key", "model": "model-name" # defaults to gemini-2.0-flash-exp } -
Direct Initialization
from fileai.api import GeminiAPI api = GeminiAPI(api_key="your-api-key")
The API key precedence is:
- Direct initialization
- Configuration file
- Environment variable
# Basic usage
fileai input_directory output_directory gemini
# With API key provided via command line
fileai input_directory output_directory gemini --api-key your-api-key
# With custom model
fileai input_directory output_directory gemini --model gemini-pro-vision
from fileai import FileOrganizer
from fileai.api import GeminiAPI
# Initialize the API client (will use config file or environment variables if not provided)
api = GeminiAPI(api_key="your-api-key") # api_key is optional if configured elsewhere
# Initialize the organizer
organizer = FileOrganizer(input_path="input_dir", output_path="output_dir", api=api)
# Process a single file
organizer.process_file("path/to/your/file.pdf")
# Process a directory
organizer.process_directory("path/to/your/directory")- Automatically analyzes documents using AI
- Organizes files into appropriate categories
- Generates descriptive filenames based on content
- Supports various file types:
- PDF documents
- Images (jpg, png, etc.)
- Text files
- Office documents (docx, xlsx, etc.)