Skip to content

About

Linux daemon that automatically renames screenshots using Claude AI vision

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

screenshot-renamer

License: MIT

Rename screenshots automatically using Anthropic Claude. This lightweight daemon watches a directory, generates descriptive filenames, and renames image files safely.

Features

  • Watches a screenshot folder and renames new images automatically
  • Uses Claude to generate meaningful, sanitized filenames
  • Supports catch-up mode to rename existing screenshots
  • Preserves file extensions and avoids name collisions
  • Logs to both stdout and a rotating log file
  • Tracks renamed files to prevent duplicate processing

Prerequisites

  • Python 3.8+
  • Linux with inotify support
  • An Anthropic API key

Installation

  1. Create and activate a virtual environment.
  2. Install dependencies.
  3. Install the package in editable mode.
  4. Install the systemd user service (optional).
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
pip install -e .
chmod +x install-service.sh
./install-service.sh

After installation, edit ~/.config/screenshot-renamer/config.json and set api_key.

Configuration Config file location: ~/.config/screenshot-renamer/config.json

Example:

{
  "api_key": "YOUR_ANTHROPIC_API_KEY_HERE",
  "model": "claude-haiku-4-5-20251001",
  "max_filename_length": 60,
  "write_settle_seconds": 1.5
}

Options:

  • api_key (required): Your Anthropic API key. Get one at https://console.anthropic.com/settings/keys
  • model (optional): Claude model to use. Valid values: claude-haiku-4-5-20251001, claude-sonnet-4-5-20250929, claude-opus-4-5-20251101. Defaults to claude-haiku-4-5-20251001.
  • max_filename_length (optional): Maximum filename length (default: 60).
  • write_settle_seconds (optional): Delay before processing a new file to let writes finish (default: 1.5).

Related files created at runtime:

  • ~/.config/screenshot-renamer/renamed.json tracks original-to-new names
  • ~/.config/screenshot-renamer/renamer.log stores logs (rotated)

Usage

Systemd Service

# Install and enable the user service
./install-service.sh

# Check status
systemctl --user status screenshot-renamer

# Follow logs
journalctl --user -u screenshot-renamer -f

# Restart after config changes
systemctl --user restart screenshot-renamer

Manual Operation

# Default watch directory: ~/Pictures/Screenshots
python3 -m screenshot_renamer.watcher

# Provide a directory via env var
SCREENSHOT_DIR="$HOME/Pictures/Screenshots" python3 -m screenshot_renamer.watcher

# Provide a directory via CLI
python3 -m screenshot_renamer.watcher --dir "$HOME/Pictures/Screenshots"

# One-time catch-up rename for existing screenshots
python3 -m screenshot_renamer.watcher --catch-up

# Catch-up then continue watching
python3 -m screenshot_renamer.watcher --catch-up --watch

Project Structure

screenshot-renamer/
|-- src/
|   `-- screenshot_renamer/
|       |-- __init__.py
|       |-- llm_client.py
|       |-- extractor.py
|       |-- sanitizer.py
|       `-- watcher.py
|-- install-service.sh
|-- screenshot-renamer.service
|-- README.md
`-- requirements.txt

Behavior Notes

  • The watcher uses inotify events and waits 1.5s before processing new files.
  • Only image files (.png, .jpg, .jpeg, .webp) are processed.
  • Filenames are sanitized with the original file extension preserved.

Troubleshooting

  • Missing config file error: Create ~/.config/screenshot-renamer/config.json and set api_key.
  • Service starts but renames nothing: Confirm the watch directory is correct and contains supported image files.
  • Unknown model warning: Use one of the supported model names listed in the Configuration section.
  • Permission errors: Ensure the service user can read/write the screenshot directory.
  • No events detected: Verify inotify support and confirm the directory exists.

Contributing Contributions welcome. Please open an issue or pull request.

License MIT License. See LICENSE.

About

Linux daemon that automatically renames screenshots using Claude AI vision

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages