ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: mklein on November 30, 2013, 08:20:13 AM

Title: Question regarding ExifTool statements
Post by: mklein on November 30, 2013, 08:20:13 AM
Hi,

could you explain the following statements to?

1.)

-execute "-IPTC:Keywords-<$XMP:Country" "-XMP:Subject-<$XMP:Country"

I think this will delete the value of the country field (e.g. "Austria") from the IPTC keywords as well as from the XMP keywords. Is this correct?

2.)

-execute "-XMP:Subject+<$XMP:Country" -if "not $XMP:Subject=~/$XMP:Country/" -execute "-IPTC:Keywords+<$XMP:Country"

I think this creates a new IPTC and XMP keyword with the value of the country field, right? But does the if statement do? And what does "=~" mean and what are the "/" for? Could you explain these three statements please?


Thanks a lot

Regards
Michael
Title: Re: Question regarding ExifTool statements
Post by: Phil Harvey on November 30, 2013, 10:43:20 AM
Hi Michael,

Quote from: mklein on November 30, 2013, 08:20:13 AM
-execute "-IPTC:Keywords-<$XMP:Country" "-XMP:Subject-<$XMP:Country"

I think this will delete the value of the country field (e.g. "Austria") from the IPTC keywords as well as from the XMP keywords. Is this correct?

Yes, but the -execute is extraneous in this context (either that, or it should appear after the arguments), and I would recommend dropping the "$" sign:

"-IPTC:Keywords-<XMP:Country" "-XMP:Subject-<XMP:Country"

Quote-execute "-XMP:Subject+<$XMP:Country" -if "not $XMP:Subject=~/$XMP:Country/" -execute "-IPTC:Keywords+<$XMP:Country"

I think this creates a new IPTC and XMP keyword with the value of the country field, right?

Yes, but my previous comment applies.  Another way to do this is:

"-XMP:Subject-<XMP:Country" "-XMP:Subject+<XMP:Country"

which avoids one pass to read the metadata first, but will write all files regardless of whether or not the country was in the subject beforehand.

QuoteBut does the if statement do? And what does "=~" mean and what are the "/" for? Could you explain these three statements please?

From the exiftool application documentation:

       -if EXPR
            Specify a condition to be evaluated before processing each FILE.
            EXPR is a Perl-like logic expression containing tag names prefixed
            by "$" symbols.  It is evaluated with the tags from each FILE in
            turn, and the file is processed only if the expression returns
            true.  [...]

The Perl "~=" operator applies a regular expression to a variable.  In the simplest form, it looks for a matching substring within the variable.  Google "Perl regular expressions" for all of the details.

- Phil
Title: Re: Question regarding ExifTool statements
Post by: mklein on December 02, 2013, 02:44:40 PM
Hi Phil,

Thanks a lot, I solved my problems now.

But there's one question left. I want to delete a XMP keyword that's called "99 - LOCATION".
What is the statement to delete this keyword via ExifTool?

I tried: "-XMP:Subject-<99 - LOCATION"
But this didn't work - I think it's because of the symbol "-".

How can I delete this keyword?

Thanks again

Regards,
Michael
Title: Re: Question regarding ExifTool statements
Post by: Phil Harvey on December 02, 2013, 04:14:32 PM
Hi Michael,

Quote from: mklein on December 02, 2013, 02:44:40 PM
I tried: "-XMP:Subject-<99 - LOCATION"

This doesn't work because there is no tag name called "99 - LOCATION".

If you want to delete a specific value, use -=, not -<.

- Phil