From c077c535b38925ee7ea8e4b2994a4c0494fce995 Mon Sep 17 00:00:00 2001 From: ergosteur Date: Sun, 26 Jul 2026 16:11:06 -0400 Subject: [PATCH] Add camera-raw format support (.arw/.cr2/.dng/.raw) Verified via exiftool against real Sony ARW, Canon CR2, and Pixel DNG files pulled from are-nas -- same EXIF DateTimeOriginal/CreateDate tags as JPEG, no new codepath needed. Co-Authored-By: Claude Sonnet 5 --- README.md | 3 ++- set_mtime_from_metadata.py | 14 +++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f02f507..43a0086 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,8 @@ Handles `.mov`/`.mp4`/`.m4v` (ffprobe container tags, preferring Apple's `creation_time`, usually UTC; falls back to exiftool's QuickTime atoms if neither ffprobe tag is present), `.avi` (exiftool's RIFF `DateTimeOriginal`), and photo formats — `.jpg`/`.jpeg`/`.png`/`.tif`/`.tiff`/`.heic`/`.heif` -(exiftool's EXIF `DateTimeOriginal`). Values with no timezone offset are +plus camera-raw `.arw`/`.cr2`/`.dng`/`.raw` (all via exiftool's EXIF +`DateTimeOriginal` — raw formats carry standard EXIF too). Values with no timezone offset are interpreted as this machine's local time (DST-aware) — run it somewhere with the same system timezone the footage was actually shot in. Placeholder "clock never set" timestamps some cameras write (e.g. literal diff --git a/set_mtime_from_metadata.py b/set_mtime_from_metadata.py index cf2c88f..33796fc 100755 --- a/set_mtime_from_metadata.py +++ b/set_mtime_from_metadata.py @@ -19,9 +19,10 @@ Handles, in priority order per format: .avi -- exiftool's RIFF DateTimeOriginal (IDIT chunk). This is the camera's own local wall-clock time with no timezone info, unlike the QuickTime tags above. - .jpg/.jpeg/.png/.tif/.tiff/.heic/.heif - -- exiftool's EXIF DateTimeOriginal. Also local wall-clock - time with no timezone info. + .jpg/.jpeg/.png/.tif/.tiff/.heic/.heif/.arw/.cr2/.dng/.raw + -- exiftool's EXIF DateTimeOriginal (the .arw/.cr2/.dng/ + .raw camera-raw formats carry standard EXIF too). + Also local wall-clock time with no timezone info. Values with no timezone offset (AVI, EXIF, and ffprobe's bare creation_time fallback path is UTC-aware so it's unaffected) are interpreted using this @@ -60,7 +61,10 @@ QUICKTIME_TAG_PRIORITY = ["com.apple.quicktime.creationdate", "creation_time"] QUICKTIME_EXTS = {".mov", ".mp4", ".m4v"} AVI_EXTS = {".avi"} VIDEO_EXTS = QUICKTIME_EXTS | AVI_EXTS -EXIF_PHOTO_EXTS = {".jpg", ".jpeg", ".png", ".tif", ".tiff", ".heic", ".heif"} +EXIF_PHOTO_EXTS = { + ".jpg", ".jpeg", ".png", ".tif", ".tiff", ".heic", ".heif", + ".arw", ".cr2", ".dng", ".raw", # camera raw formats -- standard EXIF via exiftool +} ALL_SUPPORTED_EXTS = VIDEO_EXTS | EXIF_PHOTO_EXTS # Synology (and other NAS/sync tool) internal housekeeping directories that @@ -190,7 +194,7 @@ def main(): parser.add_argument("files", nargs="*", type=Path, help="Media files to fix") parser.add_argument("--dir", type=Path, help="Recursively scan this directory for supported files instead of (or in addition to) explicit FILES") type_group = parser.add_mutually_exclusive_group() - type_group.add_argument("--only-photo", action="store_true", help="Only consider photo formats (jpg/jpeg/png/tif/tiff/heic/heif)") + type_group.add_argument("--only-photo", action="store_true", help="Only consider photo formats (jpg/jpeg/png/tif/tiff/heic/heif/arw/cr2/dng/raw)") type_group.add_argument("--only-video", action="store_true", help="Only consider video formats (mov/mp4/m4v/avi)") parser.add_argument("--dry-run", action="store_true", help="Show what would change without modifying anything or prompting") parser.add_argument("--yes", "-y", "--unattended", dest="yes", action="store_true", help="Apply changes without an interactive confirmation prompt")