#How to sort by date

1 messages · Page 1 of 1 (latest)

topaz narwhal
#

I've got many images & videos that are not properly sorted, look at this screenshot: this as many other appear to be in 2024 but if you read the name of the file, it's from 2023.

Is there a way to fix this?

fervent hullBOT
#

:wave: Hey @topaz narwhal,

Thanks for reaching out to us. Please follow the recommended actions below; this will help us be more effective in our support effort and leave more time for building Immich immich.

References

Checklist

  1. :blue_square: I have verified I'm on the latest release(note that mobile app releases may take some time).
  2. :blue_square: I have read applicable release notes.
  3. :blue_square: I have reviewed the FAQs for known issues.
  4. :blue_square: I have reviewed Github for known issues.
  5. :blue_square: I have tried accessing Immich via local ip (without a custom reverse proxy).
  6. :blue_square: I have uploaded the relevant logs, docker compose, and .env files, making sure to use code formatting.
  7. :blue_square: I have tried an incognito window, disabled extensions, cleared mobile app cache, logged out and back in, different browsers, etc. as applicable

(an item can be marked as "complete" by reacting with the appropriate number)

If this ticket can be closed you can use the /close command, and re-open it later if needed.

twin summit
#

Judging by the file name that seems to be a whatsapp video?

topaz narwhal
#

yeah

twin summit
#

Whatsapp really butchers metadata, so it's expected to fail

#

Like, the image basically has nothing else except the filename

#

Only thing you can do is fix the metadata yourself beforehand, either with some script or by doing it manually

topaz narwhal
#

oh

#

so there's no way to make it automatic with immich? just by reading the file name

twin summit
#

Nope. A file name isn't really explicit enough. There are like a million different ways of how you can write some sort of date in there, so it's really not something immich can/should fix

#

Just because you'd need to add edge cases for way too many services, and presumably also take care of different regions, idk

#

For instance the file name lacks a timezone

#

Or a time in general

topaz narwhal
#

So if I make a script that modifies the metadata of each image in the folder used by immich it wont break it right? like, the image hash or whatever mechanism immich uses to recognise an already uploaded image

twin summit
#

You would need to upload the assets again for immich to recognize them

topaz narwhal
#

🥲

twin summit
#

Or well, re-running metadata extraction should also fix it

topaz narwhal
#

oh

topaz narwhal
#

The program I made looks for files like Pattern.compile("IMG-(\\d{8})-WA\\d+\\.jpg") as their name, extract the date and puts it in their metadata buuuuut now that i just need to run it, im not sure where are those images supposed to be 😅

twin summit
#

Right, so you have two options Either fix the metadata beforehand and re-upload, or use the storage template to give the files their original name first

topaz narwhal
#

ugh im trying to understand how it works... (the storage template) do you know how could I do that?

topaz narwhal
twin summit
topaz narwhal
#

ok srry ;)
My program can edit each .jpg metadata it finds, it worked on files with the name like IMG-20230707-WA0024.jpg but clearly immich renamed them all... (tell me pls if there are faster way to do this, it's just the first idea I've got).
So now I either can extract the date from the new name immich gave to the photos or I find a way to get them to have their old names back... You suggested me to use the storage template. Would it work with already stored images? how can I used it torename all the images to its orginal names?

twin summit
stuck fable
#

In storage template, you can make immich use the actual image name:

So..do that..then run storage migration job..then make your program edit those files

twin summit
#

I'd add the "check the files got renamed" step but otherwise that sounds about right, yep

topaz narwhal
stuck fable
#

Also - I use whatsapp extensively, so, I get your feeling.

I run this command using exiftool every month - to make sure all my whatsapp assests have the correct exif date.. It was a pain to fix all those images when I moved from google photos to immich.

LIBRARY_PATH="/mnt/user/images/immich/library"

For Images
exiftool "-alldates<filename" -r -P -overwrite_original -if '((not $datetimeoriginal) and ($filetype eq "HEIC" or $filetype eq "JPEG" or $filetype eq "jpg" or $filetype eq "scr"))' "$LIBRARY_PATH"

For videos
exiftool "-AllDates<filename" -r -P -api:QuicktimeUTC -api largefilesupport=1 -overwrite_original -if '(((not $Quicktime:CreateDate) or ($Quicktime:CreateDate eq "0000:00:00 00:00:00")) and ($filetype eq "MP4" or $filetype eq "MOV"))' "$LIBRARY_PATH"

PLEASE MAKE SURE YOU HAVE BACKUPS! AND TEST THESE COMMANDS BEFORE YOU RUN ON THE ENTIRE LIBRARY. It replaces the original assets with the edited one. So, there is always a chance to mess things up.

twin summit
#

Or did they have the incorrect metadata in gphotos as well?

stuck fable
#

There was no immich-go at that time...my bad luck! lol

stuck fable
stuck fable
twin summit
twin summit
#

It's just whatsapp doing a really bad job (although you might say that's good with regards to privacy)

stuck fable
#

Yeap. Definitely good for privacy...My parents would just share their location to the world that way! haha

twin summit
#

But yeah

topaz narwhal
twin summit
#

Reorder?

#

You mean telling immich to extract metadata again?

topaz narwhal
#

yeah, I think I just did it, it's working on it rn

stuck fable
#

@native bay Yeah. I use ios, and the file name is just a random id. But if you think the data shown on immich is correct, then the following will work.

Enable the storage template and use a format like:
{{y}}-{{MM}}-{{dd}}-T{{HH}}-{{mm}}-{{ss}}
You will get a file name like 2022-02-03-T04-56-05.jpg

Then you can use the commands I used to basically set all the exif tags from the filename set by immich. This is what I do, and it works great so far.