Is it possible to get a tag via -tagsFromFile only if not already set

Started by c++, October 20, 2014, 03:39:33 PM

Previous topic - Next topic

c++

I have a quick question: Is it possible to get a tag via -tagsFromFile only if that tag is not already set? I'd like to do that in a single command line that does other things as well. If I read it right the -if flag would cancel the whole command's execution if false. What I rather seek is preventing to overwrite a specific tag in case of it being already populated.

Phil Harvey

You want to conditionally replace an individual tag if it doesn't exist.  This is done like this:

exiftool -TAG-= -TAG=NEWVAL ...

You may use -TAG-=OLDVAL to replace the tag if it had value OLDVAL, but if OLDVAL is omitted then the tag is written only if it didn't exist before.

- Phil

Edit:  Sorry, I neglected to put this in the context of -tagsfromfile.  This is the command to do that:

exiftool -TAG-= -addtagsfromfile @ "-TAG<SOMEOTHERTAG" ...

Note that you must use -addTagsFromFile instead of -tagsFromFile, otherwise the original assignment is superceded.
...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 ($).

c++

Thank you very much. That is exactly what I need. Also thanks for pointing out -addTagsFromFile.