conditionally appending caption-abstract and keywords

Started by photo_n00b, September 05, 2011, 12:42:45 AM

Previous topic - Next topic

photo_n00b

Hello,
I'm using exiftool standalone v8.50 on Windows 7 64 bit. If Caption-Abstract is not empty, I would like to append keywords to Caption-Abstract such that value of Caption-Abstract is:

Image Caption: "Here is a caption" Image Keywords=keyword1, keyword2....

If Caption-Abstract is empty, I would like to set keywords in Caption-Abstract such that value of Caption-Abstract is:

Image Keywords=keyword1, keyword2....

The following command successfully satisfies the first scenario:
exiftool -P -m "-Caption-Abstract<Image Caption=\"$Caption-Abstract\" Image Keywords=$keywords" -if "$Caption-Abstract =~ /.+/i" -ext JPG -ext GIF .

But when I try and include the second scenario with the following command, both conditions fail:
exiftool -P -m -if "$Caption-Abstract =~ /.+/i" "-Caption-Abstract<Image Caption=\"$Caption-Abstract\" Image Keywords=$keywords" -execute -if "$Caption-Abstract =~ /^$/i" "-Caption-Abstract<Image Keywords=$keywords" -common_args -ext JPG -ext GIF .

Any thoughts on what I'm doing wrong?

TIA.




Phil Harvey

The problem is your -if condition of your second command.

Testing /^$/i will only return true if the caption-abstract exists but is empty, but I suspect that you want it to return true if the caption-abstract is missing.

I suggest using simply: -if "not $caption-abstract"

This will return true if any of the following is true:

1) Caption-Abstract doesn't exist.
2) Caption-Abstract is empty (ie. "").
3) Caption-Abstract is zero (ie. "0").

Similarly, I would suggest using -if "$caption-abstract" for your first command.

- Phil

P.S.  It is refreshing to see that someone that reads the documentation. :)
...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 ($).

photo_n00b

lol! Yup I do my best to RTFM before posting. :)  Thanks for your assistance, your suggestion solved my problem.