Copying Filename with keywords separated by dahses to Keywords field

Started by AlphaTag, July 24, 2023, 07:18:41 PM

Previous topic - Next topic

AlphaTag

I am copying the content in the Filename to the Keywords field and I want to remove the "-" dashes and replace them with semicolons, indicating each word is a separate keyword.

The filename has dashes separating words "models-decision-..." and I want to replace the dashes when I move, such that each word becomes a separate keyword, so: models; decision; ...

This code works to put the filename words into the Keywords field, but it sees it all as one keyword, because in Bridge the set of keywords has quotes around it.

exiftool *.ai *.psd *.jpg *.jpeg *.png *.indd *.tif *.pdf "-Keywords<${filename;s/\..*?$//;tr/-/;/}" - sep

What can I do to change this code so that it will replace all dashes with semicolons and see each word as a separate keyword. Thank you.

StarGeek

You have a space between the hyphen and the sep and then you don't have a character to actually sep on.  See the -sep option.

It's much better to use -ext (-extension) option instead of wildcards, especially if you plan on recursing into subdirectories at some point.  See Common Mistake #2.

Also, use Basename instead of Filename and you don't have to worry about the extension.

exiftool -ext ai -ext psd -ext jpg -ext jpeg -ext png -ext indd -ext tif -ext pdf -sep ; "-Keywords<${Basename;tr/-/;/}" /path/to/files/
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).