Writing invalid dates

Started by mazeckenrode, January 02, 2021, 01:19:57 AM

Previous topic - Next topic

mazeckenrode

I've been using the following command successfully for months now, with the resulting date value visible in Directory Opus via tooltip or metadata panel:

ExifTool "-EXIF:DateTimeOriginal<filename" "-XMP:DateTimeOriginal<filename" "-IPTC:DateCreated<${filename;m/^(\d{4})[-_;\., ]*(\d{2})[-_;\., ]*(\d{2})/;$_=$1.$2.$3}" "-IPTC:TimeCreated<${filename;m/^\d{4}[-_;\., ]*\d{2}[-_;\., ]*\d{2}[-_;\., ]*(\d{2})[-_;\., ]*(\d{2})[-_;\., ]*(\d{2})/;$_=$1.$2.$3}" .

A few days ago, I inadvertantly* used the same command on a set of image files in whose names I represented the date December 1952 (no specific day number) as 1952-12-00. Full example filename: "1952-12-00 01;41;00 - Farm Journal - 101.jpg".

(* Meaning I completely overlooked the fact that I was running the command on filenames with presumably invalid date representations.)

After banging my head against the wall for a while, trying to figure out why Directory Opus wouldn't display the date tags I'd just set, I posted in the Directory Opus help forum, where another user kindly pointed out that ExifTool had apparently written the invalid date representation without any complaint, and not surprisingly, Directory Opus declined to display the tags as written.

I've read the ExifTool FAQ entry on date and time formats, and did some searching in the forums, but haven't been able to locate any reference to date/time tags getting successfully written with a value of 0 for the day number. Is ExifTool supposed to do this, and not even give a warning about it? I could see it being potentially useful in certain circumstances, such as the 0-as-day-number getting ignored in an operation that sets XMP:DateTimeOriginal to year and month and possibly time value. (Is there any actual way to do that now?) Or, I could see making it so that any value of 0 encountered for the day number would be automatically bumped to 1 when writing any of the applicable date/time tags. Or at least give a warning.

Phil Harvey

You're right.  ExifTool doesn't complain about a zero day or month.  I'll add a check for this and issue a warning and avoid writing date/time values like this.  Thanks for the suggestion.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).