Remove the same word from several files leaving all the rest unchanged

Started by sal261, January 31, 2013, 04:53:13 PM

Previous topic - Next topic

sal261

Hi,
i'm new to exiftool and i need to remove a common word from thousand of jpeg files.

The word is under the exif tag ImageDescription, but only that word is in common with all the files.

For example, i have one jpeg that under ImageDescription  looks like this:

ImageDescription: Rome, London, Paris

and another one that looks like this:

ImageDescription: New York, Berlin, Paris

i would like to remove Paris leaving intact all the rest.

Tried with the gui tool, but it apply the keywords of the first picture to all others, then tried the command line, but i got errors and i think i need some help.

Thank you

Sal

Phil Harvey

Hi Sal,

With ExifTool 9.15 (or later), you could do this:

exiftool "-imagedescription<${imagedescription;s/Paris, //;s/, Paris//}" DIR

where DIR is the name of the directory containing the images.

If you want to avoid processing images without "Paris", add this to the command:

-if "$imagedescription=~/Paris/"

Note that I had to do 2 substitutions here to handle the case where "Paris" is at the start and middle, or end of the string.

- Phil

P.S.  This solution is maybe a bit advanced for the "newbie" section of the forum
...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 ($).