Delete specific word from the iptc

Started by llp185, March 07, 2019, 11:02:45 AM

Previous topic - Next topic

llp185

Hello everyone, first of all sorry for my english.

I would like to know if it is possible to delete a specific word from the field iptc:LocalCaption.

I'm triying this: -iptc:LocalCaption-Abstract-="Specific Word" *.jpg

but the answer is: 5 image files unchanged.

Thanks!

Phil Harvey

What you have tried would work with a list-type tag, but IPTC:LocalCaption is a simple string, not a list.

Removing a word from inside a string is tricky because it may have a space before or after it, or neither.  Also, what do you want to do if the caption is "This is a test. Another thing here" and you want to remove the word "test"?  Also, is capitalization significant?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

llp185

Thank you very much for the reply, Phil.

Another question, could the last word of the caption be deleted?

For example: Caption: "This is a test. Another thing here".

I would like to delete the word "here".

Thanks!

Phil Harvey

Sure.  Assuming you mean IPTC:LocalCaption again, this should do it:

exiftool "-iptc:localcaption<${iptc:localcaption;s/\s+\S+$//}" FILE

This will also remove the space before "here" and the period after.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

llp185

Perfect! just what I needed!

Thanks Phil!