Add tag but only if they exist and has value?

Started by RobiWan, January 10, 2018, 12:40:44 AM

Previous topic - Next topic

RobiWan

Hi,

is there a way to add tag(s) - in my case "Subject" and "HierarchicalSubject" to xmp file but only if they exist?
I would like to so something like this:

exiftool -if "$xmp-xmp:Subject (is not empty)" -HierarchicalSubject+='My Keyword' -Subject+='MyKeyword' FILE

Robert

StarGeek

If Subject exists (as in your example) or only if both Subject and HierarchicalSubject exists?

In the first case
exiftool -if "defined $subject" -HierarchicalSubject+="My Keyword" -Subject+="MyKeyword" FILE

In the second,
exiftool -if "defined $subject and defined $HierarchicalSubject" -HierarchicalSubject+="My Keyword" -Subject+="MyKeyword" FILE

Change double quotes to single quotes if on mac/linux.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype