A Python script to automatically rename Mac screenshots using OCR and local LLM summarization.
- Scans your Desktop for new screenshots (PNG files starting with "Screen").
- Extracts text from screenshots using Tesseract OCR.
- Summarizes the content using a local LLM (Ollama + Llama 3).
- Renames screenshots to a concise summary, preserving the original timestamp.
- Logs both old and new filenames for tracking.
- Designed to run automatically (e.g., via cron).
- Python 3.8+
- Tesseract OCR
- Ollama with the
llama3model - Python packages:
pillow,pytesseract,requests
git clone https://github.com/yourusername/rename-screenshots.git
cd rename-screenshotsCreate a new virtual environment (replace venv with your preferred name):
python3 -m venv venvActivate the virtual environment:
- On macOS/Linux:
source venv/bin/activate - On Windows:
venv\Scripts\activate
With your virtual environment activated, run:
pip install -r requirements.txtOn macOS (using Homebrew):
brew install tesseractOn Ubuntu/Debian:
sudo apt-get install tesseract-ocr- Download and install from Ollama.
- Pull the Llama 3 model:
ollama pull llama3
- Start Ollama (if not already running):
ollama serve
By default, the script processes PNG files on your Desktop. If you want to change the directory, edit the SCREENSHOT_DIR variable in screenshot_renamer.py.
Activate your virtual environment if not already active:
source venv/bin/activateThen run:
python screenshot_renamer.py- Find the full path to your Python executable in the virtual environment:
which python # Example output: /Users/yourusername/rename-screenshots/venv/bin/python - Find the full path to your script:
pwd # Example output: /Users/yourusername/rename-screenshots
- Edit your crontab:
crontab -e
- Add the following line to run the script every hour (replace paths as needed):
0 * * * * /Users/yourusername/rename-screenshots/venv/bin/python /Users/yourusername/rename-screenshots/screenshot_renamer.py - Save and exit the editor. The script will now run every hour.
The script creates a processed_files.txt file in the same directory, logging both the old and new filenames for each processed screenshot.
MIT License