ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Koala on October 31, 2016, 12:07:07 PM

Title: [solved] How to convert keywords to lower case spelling?
Post by: Koala on October 31, 2016, 12:07:07 PM
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

Title: Re: How to convert keywords to lower case spelling?
Post by: Phil Harvey on October 31, 2016, 12:24:03 PM
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
Title: Re: How to convert keywords to lower case spelling?
Post by: StarGeek on October 31, 2016, 12:33:29 PM
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
Title: Re: How to convert keywords to lower case spelling?
Post by: Phil Harvey on October 31, 2016, 12:56:03 PM
@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
Title: Re: How to convert keywords to lower case spelling?
Post by: Koala on October 31, 2016, 03:49:29 PM
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
Title: Re: [solved] How to convert keywords to lower case spelling?
Post by: Koala on November 03, 2016, 08:36:12 AM
to use it recursively you need -r
exiftool -r -if '$keywords# ne $keywords' -api 'Filter=$_=lc' -tagsfromfile @ -keywords Dir/

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