Setting DateTimeOriginal from YYYY & MM from filename + dummy day & time

Started by Bob_K, January 12, 2022, 06:19:50 PM

Previous topic - Next topic

Bob_K

Similar to Topic started by: erodrigues on November 22, 2021, 11:52:22 AM, Title: "How to set new date from filename + set dummy time?", but I haven't been successful trying to extrapolate from that.

The previous case addressed a "digital-origin realm" filename format example of IMG-20180205-WA0060.jpg, where the YYYYMMDD is present in the filename.

My case is for a "film-scan realm" filename format of YYYY-MM-ROLLID-NEGID.jpg, e.g.: 1998-02-P318-07.jpg. Where YYYY-MM represents when the roll was started (or best guess thereof). An occasional variation on the format is an optional letter (a, b, c etc.) suffix to the MM, e.g. "1998-02a-P318-07.jpg. (This is an artifice to maintain chronological filename sorting in a few cases where rolls/cameras overlap each other.)

All files semi-manually re-named post-scanning from original IMGxxxxx.jpg filenames. The existing exif time values represent when the frame was scanned, which is of little practical value.

What I want is to "easily" get the DateTimeOriginal value into the rough ballpark of what it should be.

The notion is the take the YYYY-MM from the filename and combine it with a fixed DD:HH:MM:SS (e.g., 01:12:00:00) and stuff that into DateTimeOriginal.

Similar to the prior topic , so I started with StarGeek's solution to that case:
exiftool '-CreateDate<${FileName;m/(\d{8})-wa/i;$_=$1} 00:00:00' /path/to/files/

After a bit of cogitation / experimentation on that I eventually realized that it's out of my league as far as understanding the Advanced Formatting Features and Perl expressions embedded there.

So, would someone be so kind as to help me out here?





StarGeek

Give your format of 4 digits Dash 2 digits, your command would
exiftool "-DateTimeOriginal<${Filename;m/^(\d{4}-\d\d);$_=$1} 01 12:00:00" /path/to/files/
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Bob_K

Not quite. The formatting returned "1998-08-P332-02.JPG 01 12:00:00", which I determined from putting it into -comment, instead of -datetimeoriginal after it refused to update dto.


C:\Users\rober> exiftool "-DateTimeOriginal<${Filename;m/^(\d{4}-\d\d);$_=$1} 01 12:00:00" "C:\Users\rober\Pictures\1968-2003\SANDBOX - BFC Dating\1998-08-P332-02.JPG"
Warning: [minor] Unrecognized MakerNotes - C:/Users/rober/Pictures/1968-2003/SANDBOX - BFC Dating/1998-08-P332-02.JPG
Warning: No writable tags set from C:/Users/rober/Pictures/1968-2003/SANDBOX - BFC Dating/1998-08-P332-02.JPG
    0 image files updated
    1 image files unchanged

C:\Users\rober> exiftool "-Comment<${Filename;m/^(\d{4}-\d\d);$_=$1} 01 12:00:00" "C:\Users\rober\Pictures\1968-2003\SANDBOX - BFC Dating\1998-08-P332-02.JPG"
Warning: [minor] Unrecognized MakerNotes - C:/Users/rober/Pictures/1968-2003/SANDBOX - BFC Dating/1998-08-P332-02.JPG
    1 image files updated

C:\Users\rober> exiftool -comment "C:\Users\rober\Pictures\1968-2003\SANDBOX - BFC Dating\1998-08-P332-02.jpg"
Comment                         : 1998-08-P332-02.JPG 01 12:00:00


StarGeek

Sorry, forgot the last slash in the regex match
C:\>exiftool -P -overwrite_original "-DateTimeOriginal<${Filename;m/^(\d{4}-\d\d)/;$_=$1} 01 12:00:00" Y:\!temp\!aaa\1998-08-P332-02.jpg
    1 image files updated

C:\>exiftool -G1 -a -s -DateTimeOriginal Y:\!temp\!aaa\1998-08-P332-02.jpg
[ExifIFD]       DateTimeOriginal                : 1998:08:01 12:00:00
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Bob_K

Yeah, that's what I thought too ... NOT.
WORKS!
Settle for a silver star today? ::)