Ship Something 20 min
Build · A personal script
A Python tool on your machine via a coding CLI. ~20 min.
You'll build a real Python CLI on your machine via a coding CLI. The assistant will read files, run commands, and write the script — asking for your approval each time. Finished result: a tool that organises a folder of photos by date.
Install a coding CLI (one of)
Pick the one you'd use day-to-day. All work similarly.
# Claude Code: npm install -g @anthropic-ai/claude-code # Codex CLI: npm install -g @openai/codex # aider: pip install aider-chat
Running the CLI prints help (e.g. claude --version works). If install fails, ask the CLI itself for help once it's running — they're great at fixing their own setup issues.
Sign in / set your API key
Claude Code and Codex open a browser for OAuth on first run. aider reads an env var.
export ANTHROPIC_API_KEY=sk-ant-… # or OPENAI_API_KEY for GPT models
The CLI shows a prompt waiting for you to type. No auth errors.
Make a fresh project folder
In your terminal:
mkdir ~/photo-renamer && cd ~/photo-renamer
You're in an empty directory. ls returns nothing.
Start the CLI in this folder
Run whichever you installed. The CLI now sees only this folder.
claude # or codex # or aider
An interactive prompt — › or similar — ready for your first instruction.
Paste the build prompt
Copy and paste this whole block. Hit Enter.
Write a Python script called rename.py that I'll run as:
python rename.py <folder>
Behavior:
- Find every .jpg, .jpeg, .png file (case-insensitive) in <folder>.
- For each, read the EXIF DateTimeOriginal. If missing, fall back to the file's mtime.
- Sort all files by that date, ascending.
- Build a new filename: YYYY-MM-DD__NNN.ext (NNN is a zero-padded 3-digit counter per day, restarting at 001 each new date).
- Before renaming anything, print a clear plan: "old → new" for every file, then ask "Proceed? [y/N]" and read one line of stdin.
- If the answer isn't 'y' or 'Y', exit without changes.
- After renaming, print a one-line summary: "Renamed N files."
Implementation notes:
- Single .py file. Use Pillow for EXIF (or piexif if Pillow isn't available); install via pip.
- No external dependencies beyond Pillow.
- No destructive operations other than the renames the user just approved.
- Handle the case where two files would get the same target name (don't overwrite — print an error and abort).
After writing the script, create a samples/ folder with two empty .jpg files (use touch), then run the script against samples/ as a smoke test. Answer 'n' to the proceed prompt so nothing is renamed — we just want to see the plan. Approve tool actions as they come up
The CLI will ask for permission before each side-effect:
- Write rename.py — allow
- Run pip install Pillow — allow (or run yourself)
- Run mkdir samples / touch samples/*.jpg — allow
- Run python rename.py samples — allow
Read each prompt before saying yes. This is the whole safety model — never click through blindly.
You see the CLI write the file, install Pillow, create samples/, run the script, and print a "would rename" plan. You answer 'n' to its proceed prompt; nothing actually changed.
Run it on real photos
Open a separate terminal (or exit the CLI with Ctrl+C twice). Then:
cd ~/photo-renamer python rename.py ~/Pictures/SomeFolder
The plan shows old → new for every photo. Answer 'y' if you want to commit; 'n' to bail.
Add --dry-run
Go back into the CLI (it's still in the same folder). Ask for an enhancement:
Add a --dry-run flag. When set, do everything you'd do up to the "Proceed?" prompt but never actually rename — just print the plan and exit. Update the README block at the top of the file to document the flag.
The CLI edits rename.py in place. Test it: python rename.py samples --dry-run — should print the plan and exit without prompting.
Add thumbnails (optional)optional
One more, for fun:
Add a --thumbs flag. When set, after a successful rename, generate a 200x200 thumbnail of each renamed image into a thumbs/ subfolder of the input folder, preserving the new filename (so 2026-05-21__001.jpg becomes thumbs/2026-05-21__001.jpg). Skip thumbnails for non-image files. Use Pillow.
After a real rename, a thumbs/ folder appears with 200×200 JPEGs.
Make it a real tool
Add a one-line shebang and put it on your PATH:
# In rename.py, add to the very top: #!/usr/bin/env python3 # Then: chmod +x rename.py mv rename.py ~/.local/bin/photo-renamer # Now from anywhere: photo-renamer ~/Pictures/SomeFolder --dry-run
You typed photo-renamer … from any folder and it just worked. You shipped a CLI tool.
Tool is yours to keep. Come back any time — your progress is saved.