Photo Renamer
Just made Photo Renamer script
photo_renamer.sh is a cross-platform shell script for organizing messy photo/video archives into a clean, chronological folder structure based on metadata (EXIF and fallback timestamps). Designed to handle multi-device backups with duplicates, inconsistent naming, and unsorted content.
๐ You can find the full script and instructions on GitHub: photo_renamer.sh
โจ Features
- โ
EXIF-based date extraction (
DateTimeOriginal
,CreateDate
, etc.) - โ Fallback to file creation/modification time
- โ
Smart renaming to format:
YYYYMMDD-HHMMSS.ext
- โ
Optional prefix (
IMG_
,VID_
) toggle - โ Duplicate-safe: adds suffixes only when needed
- โ
Handles name collisions by appending suffixes only when needed (e.g.,
IMG_20230701-143000_001.jpg
) - โ
Idempotent: supports repeated runs with
_Renamed
exclusion - โ
MPO & RAW support (e.g.
.cr2
,.mpo
) - โ CLI preview before execution
- โ Synology-compatible & lightweight (no DB or indexing)
๐ฆ Output structure
/_Renamed/
โโโ 2023/
โโโ 07/
โโโ IMG_20230701-143000.jpg
โโโ VID_20230701-150000.mp4
โโโ โฆ
๐งช Example before and after
Before:
๐ someone_phone/backup_07/DCIM/
โโโ IMG_20210809_100101.jpg
โโโ 20200902_090143(0).jpg
โโโ VID_20220326_113304.mp4
โโโ IMG-20210902-WA0010.jpg
After:
๐ _Renamed/
โโโ 2020/09/IMG_20200902-090143.jpg
โโโ 2021/08/IMG_20210809-100101.jpg
โโโ 2021/09/IMG_20210902-000000.jpg
โโโ 2022/03/VID_20220326-093327.mp4
๐ง Usage
sh photo_renamer.sh
- Requires exiftool
- Tested on macOS, Linux, Synology DSM (with exiftool installed)
- Interactive confirmation before renaming
- Excludes already renamed folders (_Renamed, @eaDir, @Recycle, etc.)
โ๏ธ Configuration
Edit constants at the top of the script:
ADD_PREFIX=0 # 1 to enable IMG_/VID_ prefix, 0 to disable
TARGET_ROOT="./_Renamed"
๐ Why this script?
This tool was born out of frustration with 15+ years of backups from multiples
phones, cloud dumps, messily named folders and files like
IMG_20210809_100101.jpg
or [17.04.2008] - 010.mp4
. It aims to:
- unify naming
- eliminate duplicates
- allow easy merge of backups
- support future deduplication and cloud import
- handles file name collisions gracefully by preserving content and avoiding overwrites