Fixing EXIF info on images

I started using Immich and really like it. Paired with my GPU it imports and performs face detection really well. A great self-hosted solution, even if it is not yet at a v1 stable version.

I noticed when importing that some of my images had the dates wrong - set to an obvious 1979 or 1980 (I wasn’t born then!!). I currently have them set up as external libraries as I work out how it all works (I didn’t want to lost any structure to the folders just yet)

So I knocked up a simple bash script to clean it up. Its a simple script that will take all files in a folder, set the first (by filename) to the date and then increment each by 1 second. This helps to preserve the most likely right order.

Steps to clean up

Most of my photos I’ve taken on my DSLR I put in a folder of the event with the date as the suffix. So I have a good original date I can set it to.

Find files with issue

  1. In Immich, scroll to the earliest date
  2. Select a photo
  3. Select the (i) infomation icon of the photo.
  4. On the side tab, select the (i) information icon next to the file name
  5. It will show the location of the file.
  6. Open the folder in my file explorer.
  7. Take a copy locally on my laptop.

Optional - backup

If you want to be extra careful, take a copy of the files you downloaded into a separate backup folder - so you can go back if needed.

Prepare script

I use this script to run the update

#!/bin/bash

start_date="2010-12-25 09:30:00"  # Set your preferred base date
increment=1  # Time increment in seconds

counter=0
for base in $(find ./ -type f | sed -E 's/\.[^.]+$//' | sort -u); do
    new_time=$(date -d "$start_date $counter seconds" "+%Y:%m:%d %H:%M:%S")

    # Apply the same timestamp to all matching versions (JPG, CRW, THM)
    for ext in jpg JPG crw CRW thm THM; do
        file="${base}.${ext}"
        if * -f "$file" *; then
            exiftool -F "-AllDates=$new_time" -overwrite_original "$file"
        fi
    done

    ((counter+=increment))  # Increment only after processing a full set
done
  1. Change the date to match the date listed in the folder name
  2. Save it in the same folder the photo’s were added.
  3. Make executable (on Linux chmod +X [filename])
  4. Run the program - It will update the files in place.
  5. Now simply copy the files back to the original location Immich was monitoring.

Rescan

Once ready, in Immich you can force a rescan of the files.

  1. Select your name and select Administration.
  2. Go to external libraries click on the 3 dots next to the library the files reside in and choose Scan.

Auto-scan

You can optionally turn on the experimental auto-scan feature under Administration > Settings > External Library > Library Watching (EXPERIMENTAL)

fin.

personal   photography