error assigning date from filename for files without paranthesis

Started by filmgeezer, May 07, 2021, 01:27:31 PM

Previous topic - Next topic

filmgeezer

I've been trying to use the handy command to pull dates from file names and put them into alldates.

exiftool "-alldates<filename" .

For reasons I can't fathom, half the files won't update and I get this error:

Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in ExifIFD:DateTimeOriginal (PrintConvInv)

Every jpg in the folder is named the same way: YYYY-MM-DD brieftitle

For example 2000-06-26 Mauleon France.jpg

These are all scans. The only difference I can detect in any of the files is that this seems only to happen to those files to which the scanning software has not appended a serial number in parenthesis.

For instance, there are five consecutive images of the same spot, named as such:

2006-06-26 San Juan De La Pena.jpg
2006-06-26 San Juan De La Pena(2).jpg
2006-06-26 San Juan De La Pena(3).jpg
2006-06-26 San Juan De La Pena(4).jpg
2006-06-26 San Juan De La Pena(5).jpg

All will get updated date fields with the command at the top except for the one that doesn't have the serial number.

If I manually change that name as such: 2006-06-26 San Juan De La Pena.jpg --> 2006-06-26 San Juan De La Pena (1).jpg , the command works

That's an ok solution for a few images, but for a few dozen and more, I'd love to figure out what's going wrong and how to remedy it.

StarGeek

This is FAQ #5, paragraph starting "Having said this"

The tags written by AllDates require a date and a time.  For 2006-06-26 San Juan De La Pena.jpg, it can pull the date but there aren't any numbers that it can use for the time.  For 2006-06-26 San Juan De La Pena(2).jpg, because there's a 2, it will use that for the tima and the tags to 2006:06:26 02:00:00.  The file 2006-06-26 San Juan De La Pena(3).jpg will be set to 2006:06:26 03:00:00 and so on.

You can use
"-alldates<$filename 00:00:00"
instead and those without a number will have the time set to 00:00:00.  The other files will have the time set according to the coppy number.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

filmgeezer

Scanning again, so I had to revisit this with a related error. Since exiftool pulls the serial number (in parenthesis at the end, before the extension) as the time, it can shove bad values into the time (for instance, putting a date, the 53:00:00 as the time).

I need to
1) start appending a dummy time to the beginning of the filenames
and/or
2) figure out the correct command to pull the date from the filename then just add a time of 00:00:00

StarGeek

I bit surprised I didn't list this original, but to pull just the date from the file name, you can use this
"-AllDates<${Filename;m/(\d{4}-\d\d-\d\d);$_=$1} 00:00:00"

This will match the pattern of YYYY-MM-DD in the filename, drop everything else, and append the 00:00:00 to the end to create a proper date/time stamp.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).