- walks a folder, finds files by extension (e.g., jpg,png,pdf)
- asks a model to suggest a better base name for each file
- renames the file to "-flash" (you should change the -flash to something else)
- logs everything to the console and to
script/rename.log - writes a simple report mapping old paths to new names (optional json)
- make sure you have python 3.10+ installed
- create a virtualenv (optional but recommended)
uv venv
- install deps
uv add google-genai python-dotenv
- set your api key
- put
AI_API_KEY=your_key_herein a.envfile at the repo root, or export it in your shell
- put
uv run main.py <src_dir> <exts>- example:
uv run main.py /path/to/folder jpg,png,pdf,jpeg
- example:
RENAME_ALLOW_OVERWRITE=1allow renaming onto an existing file (default: blocked)RENAME_REPORT_JSON=/path/to/report.jsonwrite a json report of all outcomes
- the tool processes files concurrently and prints progress like
Completed N/M - large files can take longer; the run finishes once every file is done (for pdfs, it is probably better to use a pdf reader first to extract the text)
- nothing is deleted; files are only renamed in place
- if the model fails for a file, it is skipped and noted in the report
RENAME_REPORT_JSON=report.json uv run main.py ./samples jpg,png,pdf- produces
script/rename.logandreport.jsonwith a per-file status
- produces
- if you see retries or delays, the model may be busy or the file is large
- ensure
AI_API_KEYis set and valid - to avoid overwriting files with the same final name, keep
RENAME_ALLOW_OVERWRITEunset
- i dont like how long larger files take, there is probabaly some way i can optimize this. compress images, extract text from pdfs, etc.