News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Search & replace in tags, bump time for multiple files sequentially

Started by mazeckenrode, June 06, 2020, 10:45:37 PM

Previous topic - Next topic

mazeckenrode

Well, almost done, I think. My entire command line for setting EXIF/XMP:DateTimeOriginal and IPTC:DateCreated/TimeCreated, after having already used Directory Opus to set all of the above except IPTC:TimeCreated to something, is:

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}" .

Using this to set the EXIF tags results in:


Error: [minor] IFD0 pointer references previous IFD0 directory


I presume that's due to Directory Opus writing EXIF to a non-spec location, as outlined here, but am interested to learn if there's another reason for it.

I can use -m if necessary to plow through, and have successfully done so, but would rather not need to, just because I'd like to know about any other minor errors that might come up in the future, if any. I'm guessing not, other than to stop using Directory Opus to set these tags, but is there anything else I can do about it?

StarGeek

Quote from: mazeckenrode on June 26, 2020, 03:45:34 PM
Using this to set the EXIF tags results in:


Error: [minor] IFD0 pointer references previous IFD0 directory


I presume that's due to Directory Opus writing EXIF to a non-spec location, as outlined here, but am interested to learn if there's another reason for it.

Something is writing the EXIF block incorrectly.  See FAQ #20 for how to fix it (don't use that command on RAW files).  You'll have to experiment to see if DO is the problem or not.
* 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).

mazeckenrode

Quote from: StarGeek on June 12, 2020, 12:04:55 AM
Quote
The JSON files showed a handful of the EXIF tag values preceded by a question mark:
...
No question marks appeared in any tags exported from these updated PNGs, not even in the tags I hadn't changed since the earlier JSON exports. Anybody have an explanation?

No idea without actually seeing a file and figuring out what the actual character was (might not have been a ASCII question mark), but it sounds like Opus is writing something weird.

FYI, I found at least part of the reason for the mystery question marks, and it's basically me. They resulted from me copying and pasting from an ExifTool-exported UTF-8 JSON to a Windows-1252 editing tab in Notepad++ while composing my forum reply at the time. Still, curious as to why only certain EXIF tags (looks like all the unformatted text string tags) contain whatever the actual unicode character(s) is/are. Again, though, these were tags as set by Directory Opus, not by ExifTool.

mazeckenrode

Quote from: StarGeek on June 18, 2020, 01:22:48 PM
Try this, replacing TAG with the tag that has the page number data. You can repeat the first part for each tag you need to edit
exiftool "-TAG<${TAG;my $temp=$1 if $self->GetValue('FileName')=~m/0*(\d+)\./;s/\d+(\/\d+)/$temp$1/}" "-DateTimeOriginal-<0:0:${TAG;my $temp=$1 if $self->GetValue('FileName')=~m/0*(\d+)\./;m/\d+\/(\d+)/;$_=$1-$temp}" /path/to/files/

StarGeek, I've successfully used this to update values for various comment/description/subject/title metadata fields — thanks much again for that — but am now attempting to adapt it for use with several keyword metadata fields, in which I include Page1 as a keyword in scans of all pages of whatever document or publication. Based on your code above, I've come up with the following code to attempt replacing Page1 with Page# (# being the page number taken from the filename):


exiftool -m "-IPTC:Keywords<${IPTC:Keywords;my $temp=$1 if $self->GetValue('FileName')=~m/- 0*(\d+).*\./;s/(Page)\d+/$temp$1/}" "-XMP:Subject<${XMP:Subject;my $temp=$1 if $self->GetValue('FileName')=~m/- 0*(\d+).*\./;s/(Page)\d+/$temp$1/}" .


But that's resulting in 2Page, etc., instead of Page2, even though I put (Page) before \d+ in the code. What am I doing wrong?

StarGeek

The key part is here
s/(Page)\d+/$temp$1/}

The capture group here is the word Page.  That is place into variable $1$temp is the page number captured from the filename, so the result of $temp$1 is #Page.

Try changing it to $1$temp.
* 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).

mazeckenrode

Quote from: StarGeek on July 21, 2020, 05:22:42 PM
Try changing it to $1$temp.

Yep, that makes more sense now, and working beautifully with the change. Thanks again.