Conditional in argfile

Started by Alan Clifford, April 04, 2016, 04:06:58 PM

Previous topic - Next topic

Alan Clifford

I have an argfile like this:

-overwrite_original_in_place
-countrycode=US
-mwg:country=USA
-mwg:location=Seattle, Washington
-mwg:keywords-=Seattle
-mwg:keywords+=Seattle
-mwg:keywords-=Washington
-mwg:keywords+=Washington
-mwg:keywords-=USA
-mwg:keywords+=USA


What I'd like to do is test if location exists, and if it does, not overwrite the value.

I'm floundering trying to do this :(

Phil Harvey

#1
This is tricky because MWG:Location is a Composite tag that writes a number of other tags.  For non-List-type tags, the answer is simple and this is the way to write an individual tag only if it doesn't already exist:

-TAG-=
-TAG=VALUE


But for List-type tags, this doesn't work, and unfortunately MWG:Location refers to XMP-iptcExtLocationShownSublocation which is a List-type tag.

So for this specific example, the only way I can see is to use a -if condition:

-overwrite_original_in_place
-countrycode=US
-mwg:country=USA
-mwg:keywords-=Seattle
-mwg:keywords+=Seattle
-mwg:keywords-=Washington
-mwg:keywords+=Washington
-mwg:keywords-=USA
-mwg:keywords+=USA
-execute
-overwrite_original_in_place
-if
not $mwg:location
-mwg:location=Seattle, Washington


then use exiftool -@ ARGFILE -common_args FILE

- Phil

Edit: Inserted missing space in command line
...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 ($).

Alan Clifford

Thank you very much Phil.  Much appreciated.