#!/usr/bin/env python3 import subprocess, json from urllib.request import Request, urlopen API_KEY = "GsWQUTR6EXlkKp1M82jDJ3KmzhM0fMAbbIbfHDyI" API_URL = "http://localhost:2283/api" files = { "AUT_3127.jpg": "2004-03-06T00:09:40.000Z", "AUT_3128.jpg": "2004-03-06T00:09:38.000Z", "AUT_3143.jpg": "2004-03-06T00:09:22.000Z", "AUT_3260.jpg": "2007-08-20T21:46:09.000Z", "AUT_3261.jpg": "2007-08-20T21:46:10.000Z", "AUT_3263.jpg": "2007-08-20T21:46:19.000Z", "AUT_3264.jpg": "2007-08-20T21:45:51.000Z", "AUT_3265.jpg": "2007-08-20T21:45:53.000Z", "AUT_3267.jpg": "2007-08-20T21:45:55.000Z", "AUT_3269.jpg": "2007-08-20T21:45:56.000Z", "AUT_3273.jpg": "2007-08-20T21:46:20.000Z", "AUT_3274.jpg": "2007-08-20T21:46:22.000Z", "AUT_3976.jpg": "2008-09-15T13:01:38.000Z", "AUT_3977.jpg": "2008-09-15T13:01:39.000Z", "AUT_3978.jpg": "2008-09-15T13:01:41.000Z", "AUT_3990.jpg": "2008-09-15T13:01:58.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}")