[solved] How to convert keywords to lower case spelling?

Started by Koala, October 31, 2016, 12:07:07 PM

Previous topic - Next topic

Koala

Hello forum,

I am about to clean up the keywords of my image collection. I found keywords which are different only by upper case/lower case spelling:

motorbike.jpg
Keywords                        : technics, Repair,

engine.jpg
Keywords                        : Technics, repair, Engine


I would like to modify the keywords, so they are all lower case:

motorbike.jpg
Keywords                        : technics, repair

engine.jpg
Keywords                        : technics, repair, engine


As I am not yet so familiar with regular expression, I would appreciate the support of you very much.
Is there a solution with a single command line?

thanks in advance

Koala

exiftool -ver
10.16
Ubuntu 12.04



Phil Harvey

Hi Koala,

Try this:

exiftool -sep '//' '-keywords<${keywords;$_=lc}' DIR

Here I have used '//' for a separator to allow for the possibility for commas in some keywords.

- Phil
...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 ($).

StarGeek

One reason I like using the API Filter option is that you don't always need to muck about with -Sep and worry about the contents of the data.

Here's my version.
exiftool -if "$keywords# ne $keywords" -api "Filter=$_=lc" -tagsfromfile @ -keywords FileOrDir
* 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).

Phil Harvey

@StarGeek:  Nice.  Good idea.

@Koala: Use single quotes instead of double quotes because you are on Linux.

For those wondering about the difference, the interpolation of ${keywords} in the string concatenates list items using the specified separator, while copying by tag name only (-tagsfromfile @ -keywords) keeps them as individual items.

- Phil
...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 ($).

Koala

Thanks for this great support.

I tested both version of command lines in a sample directory - both worked for me.

For the big run through my collection (> 18.000 images) I may use this version:
exiftool -if '$keywords# ne $keywords' -api "Filter=$_=lc' -tagsfromfile @ -keywords FileOrDir

best regards

Koala

Koala

to use it recursively you need -r
exiftool -r -if '$keywords# ne $keywords' -api 'Filter=$_=lc' -tagsfromfile @ -keywords Dir/

(also small typo corrected (" -> '))