Find keyword, not substring

Started by obetz, October 22, 2020, 11:23:49 AM

Previous topic - Next topic

obetz

Hi all,

how can I list all files with a certain keyword, but not keywords containing the desired keyword?

-if "$Keywords =~ /foo/" triggers also on foobar or afoo, but I'm looking only for "foo".

TIA,

Oliver

StarGeek

Try this
exiftool -sep "##" -if "$Keywords=~/(##|^)foo($|##)/" /path/to/files/
"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

obetz

thanks for the quick help! I'm a bit out of practice, should have found that out on my own...

exiftool -sep "," -if "$Keywords=~/(,|^)foo(,|$)/" is even better because it doesn't restrict the keywords not to contain ##.

StarGeek

But of course you have to make sure that your keywords don't include a comma.  I always chose ## because a double hashtag seems to me to be an unlikely part of a keyword, but a comma can show up in something like "Smith, John".

It all depends upon your data set, which you would best know what it contains.  And you're not limited to only 1 or 2 characters.  A longer random string would also work, such as "68eCud8VaB", 8675309, or ETPhoneHome.

"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

obetz

correct. I thought that comma is a fixed delimiter but it isn't.