A Bash pipeline that heals EXIF and filesystem timestamps across a decade of mixed-source photos and videos, so a self-hosted Nextcloud Photos gallery actually shows them in the right order.
Nextcloud Photos orders by EXIF DateTimeOriginal — so if your archive came from phones, cameras, WhatsApp, screenshots, and a Google Takeout, your gallery is a mess. The fix isn't the gallery. The fix is the metadata.
"Great project and nice learning experience! Many other users will find this useful. 🌟" — Nextcloud, on LinkedIn
photoTakenTime.timestamp from supplemental .json sidecars, which is the most trustworthy source for phone backups.DateTimeOriginal for files that have it.mtime — so Nextcloud's indexer agrees with ls -l./var/log/nextcloud_photo_fix.log so you can audit what happened after the fact — and then occ files:scan to let Nextcloud catch up.# install prerequisites $ sudo apt install jq libimage-exiftool-perl # point it at a user's photo tree $ sudo ./fix_photo_dates.sh \ "/path/to/nextcloud/data/username/files/Photos" # then tell Nextcloud to reindex $ sudo -u www-data php occ files:scan --path=username/files/Photos
mtime, which beats the filename.grep.Most self-hosters solve this by manually curating. The tool automates the same judgement calls — which source to trust, when to leave a file alone — across tens of thousands of files without repeatedly rewriting the ones you already fixed.