#!/usr/bin/env python3 import subprocess, json from urllib.request import Request, urlopen API_KEY = "GsWQUTR6EXlkKp1M82jDJ3KmzhM0fMAbbIbfHDyI" API_URL = "http://localhost:2283/api" files = { "MVI_0440.jpg": "2015-02-07T02:06:37.000Z", "MVI_0444.jpg": "2015-02-07T01:53:45.000Z", "MVI_0446.jpg": "2015-02-07T02:03:32.000Z", "MVI_0448.jpg": "2015-02-07T01:57:12.000Z", "MVI_0454.jpg": "2015-02-07T01:53:36.000Z", "MVI_0462.jpg": "2015-02-07T02:00:27.000Z", "MVI_0463.jpg": "2015-02-07T01:57:01.000Z", "MVI_0465.jpg": "2015-02-07T02:06:22.000Z", "MVI_0466.jpg": "2015-02-07T02:03:18.000Z", "MVI_0467.jpg": "2015-02-07T02:00:18.000Z", "MVI_0468.jpg": "2015-02-07T01:56:56.000Z", "MVI_0469.jpg": "2015-02-07T02:09:17.000Z", "MVI_0470.jpg": "2015-02-07T02:06:17.000Z", "MVI_0495.jpg": "2015-02-07T02:06:01.000Z", } for fname, date in files.items(): result = subprocess.run([ "docker", "exec", "immich_postgres", "psql", "-U", "postgres", "-d", "immich", "-t", "-c", f"SELECT id FROM asset WHERE \"originalPath\" LIKE '%/2024/01/{fname}' AND \"deletedAt\" IS NULL;" ], capture_output=True, text=True) asset_id = result.stdout.strip() if asset_id: data = json.dumps({"dateTimeOriginal": date}).encode() req = Request(f"{API_URL}/assets/{asset_id}", data=data, method="PUT", headers={"x-api-key": API_KEY, "Content-Type": "application/json"}) urlopen(req) print(f"Updated {fname} -> {date[:10]}") else: print(f"NOT FOUND: {fname}")