main shell-scripts/rename-photos.sh

8 lines201 BExecutable

#!/bin/sh
# rename IMG_1234.JPG to 2025-10-03_1234.jpg using the file date
for f in IMG_*.JPG; do
[ -e "$f" ] || continue
d=$(date -r "$f" +%F)
n=${f#IMG_}
mv -n "$f" "${d}_${n%.JPG}.jpg"
done