This project automatically renames screenshots using AI-generated descriptions. It's designed to work with macOS and uses OpenAI's GPT-4 Vision model to analyze and describe screenshots.
- Automatically detects new screenshots
- Uses AI to generate descriptive names for screenshots
- Renames files with the format:
description_YYYY-MM-DD.png
- Logs actions for debugging
- macOS
- Python 3.7+
- OpenAI API key
-
Clone this repository:
git clone https://github.com/fahmidme/ai-screenshot-renamer.git cd ai-screenshot-renamer
-
Create a virtual environment and activate it:
python3 -m venv venv source venv/bin/activate
-
Install required packages:
pip install -r requirements.txt
-
Create a
.env
file in the project root and add your OpenAI API key:OPENAI_API_KEY=your_api_key_here
-
Create the screenshots directory:
mkdir -p ~/Documents/screenshots
-
Change the default screenshot save location:
defaults write com.apple.screencapture location ~/Documents/screenshots
-
Restart the SystemUIServer to apply changes:
killall SystemUIServer
-
Open Automator and create a new Folder Action:
- Launch Automator from your Applications folder.
- Choose "New Document" and select "Folder Action" as the type.
-
Configure the Folder Action:
- At the top of the window, set "Folder Action receives files and folders added to" to your screenshots folder (e.g.,
~/Documents/screenshots
).
- At the top of the window, set "Folder Action receives files and folders added to" to your screenshots folder (e.g.,
-
Add a "Run Shell Script" action:
- In the left sidebar, search for "Run Shell Script" and drag it into the workflow area.
-
Configure the Shell Script action:
- Set "Shell" to
/bin/zsh
- Set "Pass input" to "as arguments"
- Copy the contents of
screenshot_action.sh
into the script area.
- Set "Shell" to
-
Save the Folder Action:
- Choose File > Save, name it "Screenshot Renamer", and click Save.
After setup, the system will automatically process new screenshots:
- Take a screenshot (Cmd + Shift + 3 or Cmd + Shift + 4).
- The screenshot will be saved to
~/Documents/screenshots
. - The Folder Action will trigger the renaming script.
- The screenshot will be renamed with an AI-generated description and timestamp.
Check the debug_log.txt
file in the project directory for detailed logs if you encounter any issues.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is released under the Unlicense. See the LICENSE file for details.