Skip to main content

renamr

Python License PyPI CI

AI-powered CLI that renames files based on their content.

What it does

Scanned documents, downloads, and exported files often arrive with useless names like scan_001.pdf or IMG_5847.jpg. renamr reads each file — running local OCR on images and scans first, falling back to vision models only when OCR fails — sends the extracted text to an LLM, and renames the file to a structured format based on the content it actually finds.

scan_001.pdf          ->  240115_ACME_Invoice.pdf
IMG_5847.jpg          ->  241203_PostOffice_DeliveryNotice.jpg
invoice_download.pdf  ->  250110_Amazon_OrderConfirmation.pdf

Only the filename changes. Files are never modified.

Features

  • Content-aware renaming via any LiteLLM-supported provider (OpenAI, OpenRouter, Anthropic, Ollama, local models)
  • Local OCR-first extraction: images and scans are OCR'd locally before hitting the LLM
  • Optional vision fallback with configurable model for OCR failures
  • Per-inbox configuration: different templates, languages, and prompts per folder
  • iCloud evicted file handling — auto-downloads stubs via brctl before processing (macOS only)
  • Multi-inbox support — configure one or more folders in a single config
  • Configurable output language — extracted metadata returned in any language
  • Dry-run mode to preview renames without touching files
  • Undo the last run with a single command
  • Optional in-place PDF compression after renaming

Quick Start

# One-time global install
uv tool install renamr   # or: pip install renamr

# First-run setup — creates ~/.config/renamr/config.toml
renamr init

# Set your API key (for cloud providers)
export OPENAI_API_KEY="your-key"

# Preview renames
renamr run --dry-run

# Rename files
renamr run

# Undo last run
renamr undo

Override the inbox without editing config:

renamr run --inbox ~/Documents/inbox --dry-run

Configuration

renamr init creates ~/.config/renamr/config.toml by default. On Linux, XDG_CONFIG_HOME is respected, so the actual path becomes $XDG_CONFIG_HOME/renamr/config.toml when set.

New [[inbox]] Format

The config uses TOML array-of-tables syntax for per-inbox settings:

# Global defaults (used when not overridden per inbox)
language = "en"
filename_template = "{date}_{sender}_{subject}"

[[inbox]]
path = "/Users/you/Documents/Invoices"

[[inbox]]
path = "/Users/you/Documents/Scans"
filename_template = "{date}_{subject}"
language = "de"
rename_prompt = "Extract only date and subject. Ignore sender."

[llm]
model = "gpt-4o-mini"

[compress]
enabled = false
dpi = 150
jpeg_quality = 80

[logging]
level = "WARNING"
json_logs = false

Each [[inbox]] section represents one folder. Missing fields fall back to global defaults:

  • filename_template — optional override
  • language — optional override
  • rename_prompt — optional override

file_extensions and recursive remain global (no per-inbox override).

Legacy Format

The old inbox_paths = ["/path/one", "/path/two"] format is still supported but deprecated:

# DEPRECATED - still works but will be removed in a future version
inbox_paths = ["/path/to/folder"]
language = "en"
filename_template = "{date}_{sender}_{subject}"

Ollama Setup

Run renamr completely offline with a local Ollama instance.

1. Install Ollama

# macOS
brew install ollama

# Or download from https://ollama.com

2. Pull a model

ollama pull gemma4:e2b

3. Configure renamr

[llm]
model = "ollama/gemma4:e2b"
api_base = "http://localhost:11434"
temperature = 0.2

That's it. Files are processed locally with no external API calls.

Note: Ollama must be running (ollama serve) before you run renamr.

Cloud Providers

Change model and set api_base. For OpenRouter:

[llm]
model = "openrouter/openai/gpt-4o-mini"
api_base = "https://openrouter.ai/api/v1"

OpenRouter reads OPENROUTER_API_KEY from the environment of the running process. Any provider supported by LiteLLM works without code changes.

If your key is stored in Infisical, run renamr from a directory with your Infisical project configuration (environment dev):

infisical run -- renamr run --dry-run
infisical run -- renamr run

A key stored in the vault becomes available to renamr when Infisical injects it into the process. An authentication failure stops the run immediately; completed renames remain undoable.

Vision Fallback Model

For most files, local OCR extracts text without hitting the LLM at all. When OCR fails (low confidence, too few characters), renamr falls back to a vision model. By default it uses the same model configured in [llm]. To use a separate, cheaper, or local model for vision:

[llm]
model = "openai/gpt-4o-mini"            # text extraction (most files never reach this)
vision_model = "ollama/gemma4:e2b"       # vision fallback (only when OCR fails)
vision_api_base = "http://localhost:11434"

Both models can also be overridden per inbox:

[[inbox]]
path = "/Users/you/Documents/Scans"
model = "openai/gpt-4o"
vision_model = "openai/gpt-4o"

Custom Prompt

The default system prompt extracts sender, subject, and date from documents and handles German and English. To override, add a rename_prompt field to your config (globally or per-inbox):

[[inbox]]
path = "/Users/you/Documents/Receipts"
rename_prompt = """
Extract only the total amount and date from this receipt.
Return JSON: {"sender":"Store Name","subject":"Receipt $AMOUNT","date":"YYYY-MM-DD"}
"""

The full default prompt is in src/renamr/models.py.

CLI Reference

renamr init [--config PATH]     Create a config file interactively
renamr run [--config PATH]      Process files and rename them
  --dry-run                     Preview without renaming
  --inbox PATH                  Override inbox folder
  --recursive / --no-recursive  Override recursive setting
  --compress / --no-compress    Override compression setting
  --verbose                     Show sanitized diagnostic logging
renamr undo [--config PATH]     Undo the last successful run
renamr version                  Print version

undo.json is stored next to the config file. With the default setup, that means ~/.config/renamr/undo.json.

Errors and diagnostics

Normal runs show a summary and short, actionable errors. Failed runs exit with status 1. Provider authentication, access, and unavailable-model errors stop further processing. Transient errors use the configured retry limit.

Diagnostics are stored beside config.toml in renamr.log (by default, ~/.config/renamr/renamr.log). The CLI prints the path when a run fails. Use --verbose to also show diagnostic events in the terminal at DEBUG level. [logging].level controls file-only diagnostic detail; json_logs = true selects JSON output. Errors while loading the configuration use the default text format. Logs rotate at 1 MB with two backups, with owner-only read/write permissions on all log files.

Diagnostics include event names, exception types, filenames, and stack locations. Provider response bodies, exception messages, document contents, and local variable values are excluded. Runs with no successful renames preserve the previous undo record.

Privacy & Security

Additional notes:

  • Always use an https:// endpoint for api_base. An http:// URL sends file content unencrypted.
  • Keep ~/.config/renamr/undo.json private on shared systems — it contains the file paths from the last run.
  • Keep diagnostic logs private: they include local file names and stack paths.

Maintenance

This tool is maintained for personal use and published as-is. Bug reports welcome via Issues. No guaranteed response time. PRs accepted if they align with the project's scope.

See CONTRIBUTING.md for development setup.

License

MIT

Metadata

Release files for renamr 1.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for renamr 1.4.1
File Size Uploaded Provenance Actions
renamr-1.4.1.tar.gz 226.1 kB With provenance Details for renamr-1.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for renamr 1.4.1
File Interpreter ABI Platform Actions
renamr-1.4.1-py3-none-any.whl Python 3 none any Details for renamr-1.4.1-py3-none-any.whl

Total release size: 254.9 kB

Release files / renamr-1.4.1.tar.gz

Download URL renamr-1.4.1.tar.gz
Size 226.1 kB
Tags Source
SHA-256 checksum
How to use checksums
eff725af60545b8ae1a481dc6b05057f5348d769239df846fcda48a87bec87a4
BLAKE2b-256 checksum
How to use checksums
6e244acd85c2304d487a3933d372dfda4c17739ca09a6d02325cb89de9a96a40
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / renamr-1.4.1-py3-none-any.whl

Download URL renamr-1.4.1-py3-none-any.whl
Size 28.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
05f0f80ac13525ba538286375d3ba5a5c6cc599b3dde511c946082d7dcf84ec7
BLAKE2b-256 checksum
How to use checksums
1ac7ae3a4b8ef3c5e599e97a94e84d378071b6ca2b936626413989350b432c92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Security for renamr 1.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for renamr-1.4.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page