Photos Date Sort Exif Data

This is more of my findings than a support question… I’m hoping this can help other people…

im using nextcloud 19
client IOS on iPhone and iPad

When adding images to the nextcloud environment everything is dated and sorted by date correctly if it is a brand new picture taken at that time.

When things can get funky is when you’re trying to manipulate your collection of images. every time you copy a file from one disk to another the file modification information is updated. if you edit a file the file modification is updated. nextcloud and every other tool out there uses this file modification date to show the files sorted by modification date not create date. you don’t see this in IOS because when you edit an image it keeps the original image intact. in fact you can always revert to the original image on IOS.

the problems come when trying to correct this. simply updating the exif file modification time doesn’t completely fix the issue.
depending on the device the image was created on and the type of encoding some exif data may not always be present.

some of my files did not contain an exif original date so when copied to another drive the file modified date was updated moving the files to the most current date. frustrating

for files that did not have and exif date I was lucky that the original file was saved in a date format like YYYY-MM-DD_HH-MM-SS.png

Here is the process I used to correct my images

im using macOS so you may need to translate this to your OS of choice.

Tools: exiftool command line. this one tool can do it all but I find it easier to do the file rename with the gui tool ExifRenamer ExifRenamer gui

I used ExifRenamer. This tool takes the file and renames it to YYYY-MM-DD_HH-MM-SS.
I create a new folder style with the format of %Y%M

it does not update the file modified date to the correct date in batch renaming. so I do another step.

at this point all files that have a exif readable date are renamed.

Use the exiftool to set the file modify date to the file name date. keep in mind the file name must contain a 4 digit year. the ExifRenamer tool will do that for you.

exiftool -ee -r “-FileModifyDate<filename” {pathtophotots}*
-ee Extract information from embedded files
-r Recursively process subdirectories

at this point all of your files that were readable exif are renamed and the file modification date is corrected back to the create date.

I run the exiftool one more time to make sure Ive captured all variation of file issues.
exiftool -ee -r “-FileModifyDate<CreateDate” {pathtophotots}*

if there was a file that could not be renamed and it also has a create date this will correct the file modify date.

if your files are already on nextcloud filesystem your good to go to files:scan steps

if your files are in a different folder but on the same dataset/diskset. you can simply move them into the Photos folder of the user you want them in.

if your files are on a external disk you can mount the disk and copy them using cp -p the -p preserves times stamps.

once the files are in place this is the gotcha and I’m not sure if this is a bug or just the way it works.

if you can already see your files in your IOS app incorrectly date sorted you must move the folder out of the data path and perform a files:scan. when you check the IOS devices you should see no Photos. once the files:scan is complete move the Photos back into the Photos folder and perform another files:scan. when moving your files around on this step be sure to use cp -p or mv on the same disk so that time stamps are kept.

im not sure why files:scan does not update the info with the new date but I assume its because it thinks its already in the database so it skips that file info update.

your images should now show up in the correct dates.

sudo -u www php occ files:scan user or --all

one thing to keep in mind is when you move your photos out of the data directory any shares you have will get removed. you will need to put them back when you’re done.


If the renaming is done correctly it can work. The file names still aren’t very useful.

But still, as any application offers “photo management”, sorting based on any other than EXIF creation date is useless. Why doesn’t the Nextcloud Photos app already support this? Does anyone know?

I just found this ticket regarding EXIF sorting: Sorting pictures by taken date instead of modification date · Issue #87 · nextcloud/photos · GitHub

Nextcloud doesn’t support this because it is too hard, or too much work to put into actually making something work properly beside just smacking it in because you can say you have it…
Most of said issues get ignored, overlooked or you get told “Go do my work for me, or do it yourself all the way”.

Android’s auto upload function to “sort into folder by date” fucks up everything too, throwing 90% of all my images from 2018-2019 into 2021/05 folder… Simply because I transferred them from my PC.

Absolutely horrible in usage, management and anything else. You can’t even select folders to search for photos in, so it just searches everything unless you spam .nomedia files in each of the folders… Which didn’t work for me either.

Get something else that actually works, you may use Nextcloud for storing photos but my god please don’t use it for anything else, it can’t do it and I don’t see it doing anything useful in the next year(s)…

Have you tried using something alongside Nextcloud for photo management/browsing/searching? Maybe something like photoprism, jellyfin, piwigo, photonix, librephotos, or lychee?

better late than never. maybe you’ll respond…Is owncloud still an alternative? With php 7?
Nextcloud is still quite imbalanced imho. I miss good ol stable owncloud + good 3rd party sync, photo tools. That is just way more reliable.

But I did (finally) get nextcloud to work okish.

With NC 25, the Photos app has been given an overhaul, which seems to work a tad better than the last version which worked absolutely not… Whenever Owncloud is an alternative for you is something you’d have to find out for yourself,