Skip to main content

CLI tool that renames local files using AI-powered metadata extraction

Project description

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 — extracting text from PDFs, rendering pages as images for vision models, or encoding photos directly — sends a preview 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, local models)
  • PDF text extraction for text-based documents
  • Vision model support for scanned PDFs and image files
  • 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
  • Configurable output template ({date}_{sender}_{subject}), file extensions, and system prompt
  • Optional in-place PDF compression after renaming

Installation

Requires Python 3.12 or newer.

pip install renamr
uv tool install renamr

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

The full set of options:

inbox_paths = ["/path/to/your/folder"]
language = "en"
file_extensions = [".pdf", ".jpg", ".jpeg", ".png", ".txt"]
recursive = false
filename_template = "{date}_{sender}_{subject}"
# rename_prompt = "..."  # override the system prompt sent to the model

[llm]
model = "gpt-4o-mini"
api_base = ""        # leave empty for direct OpenAI; set for OpenRouter or local endpoints
temperature = 0.2
max_retries = 2
timeout = 60

[compress]
enabled = false      # re-render PDFs at lower DPI after renaming
dpi = 150
jpeg_quality = 80

[logging]
level = "WARNING"
json_logs = false

Set logging.level = "WARNING" to keep routine CLI output quiet. Use renamr run --verbose only when you want debug logging for troubleshooting.

inbox_paths accepts one or more folders. renamr run processes all of them in one pass. Use --inbox /some/folder for a one-off override without editing the config.

filename_template supports three placeholders: {date}, {sender}, {subject}. Changing the order does not affect metadata extraction — the model still returns the same fields, and renamr only changes how they are assembled into the final filename.

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

Switching providers. Change model and set api_base. For OpenRouter:

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

Then set OPENROUTER_API_KEY instead of OPENAI_API_KEY. Any provider supported by LiteLLM works without code changes.

Customizing the prompt. The default system prompt extracts sender, subject, and date from documents and handles German and English. To override, uncomment rename_prompt in config.toml and replace it with your own. The full default is in src/renamr/models.py.

Privacy & Security

[!WARNING] renamr sends file content to an external LLM API.

Depending on your configuration, this includes:

  • Extracted text from PDF and .txt files
  • Rendered page images from scanned PDFs
  • Raw image data from .jpg, .png, and other supported image files
  • Original filenames and file timestamps

This data is transmitted to your configured LLM provider and may be processed on remote servers. Do not run renamr on sensitive or confidential files unless you have reviewed and accepted your provider's data handling policy.

Run renamr run --dry-run first to confirm which files will be processed.

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.
  • Avoid sharing verbose log output publicly; failed auth responses may include API key fragments.

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

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

renamr-1.1.1.tar.gz (171.5 kB view details)

Uploaded Source

Built Distribution

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

renamr-1.1.1-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file renamr-1.1.1.tar.gz.

File metadata

  • Download URL: renamr-1.1.1.tar.gz
  • Upload date:
  • Size: 171.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for renamr-1.1.1.tar.gz
Algorithm Hash digest
SHA256 79a36f4d858179004e65f96efd1e28679fc8eca6f6b278e16da10d3be148f67c
MD5 f3e012920cac206d774d446177338e34
BLAKE2b-256 20433ddf9e6ac2edec38f743d0e3938ac134cf2198a0b7d567c069f52771db45

See more details on using hashes here.

Provenance

The following attestation bundles were made for renamr-1.1.1.tar.gz:

Publisher: release.yml on spignotti/renamr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file renamr-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: renamr-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for renamr-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9c7fe61611b74a727d79c0338459b7364c1f594aadadb6a752e0898132b059eb
MD5 a1055f9a2306edfb7ccadaa59883c891
BLAKE2b-256 e98beacfbf9d13ed7289a6f8845f842b5b3d3bb7eac4d3fe51dd7fe1edddcb8d

See more details on using hashes here.

Provenance

The following attestation bundles were made for renamr-1.1.1-py3-none-any.whl:

Publisher: release.yml on spignotti/renamr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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