ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: pfelipe on February 22, 2012, 01:40:52 AM

Title: lowercase keywords
Post by: pfelipe on February 22, 2012, 01:40:52 AM
Hi There!

Congrats to the developers (ExitTool and ExifToolGUI)! Great Tools!

Basically I'm trying to get all my keywords and make them lowercase.

Example:
From: Outdoor*Ottawa*Parliament_Hill
To: outdoor*ottawa*parliament_hill

From the topic "change description tag https://exiftool.org/forum/index.php/topic,2550.msg11285.html#msg11285 (https://exiftool.org/forum/index.php/topic,2550.msg11285.html#msg11285)", I tried the following config file:

Config File:
%Image::ExifTool::UserDefined = (
   'Image::ExifTool::Composite' => {
    Lower => {
    Require => 'Keywords',
    ValueConv => 'lc($val)',
     },
   },
);


on the command line (ExifToolGUI actually) I run:
"-keywords<lower"

The problem is:
The IPTC:keywords tag gets replaced with: "array(0x36d72b4)"

I also tried to use Require => 'Subject' with same result...
I also tried ValueConv => 'lc(@val)', but Keywords then is replaced with "1"
If I use Require -> 'Description' as the original example, and run "-Description<lower", then it is fine.

My idea here is to update either Subject or Keywords with lower cases and then copy one into the other "-Subject<Keywords".

Suggestions on how can i do this?

By the way, I'm running the windows standalone executable with ExifToolGUI.

Suggestion:
Just like %ue and %le for file extension, do you think it would be worth having an option like: "-Subject<Keywords%l" or "-Subject<Keywords%u" or anything like that (still learning the syntax for the tool)...

;- )

Thanks in advance,
Felipe.
Title: Re: lowercase keywords
Post by: pfelipe on February 22, 2012, 03:28:42 AM
Not sure if this is the best way to do it... but it worked:

found something similar in this forum and used foreach:


%Image::ExifTool::UserDefined = (
   'Image::ExifTool::Composite' => {
        Lower => {
            Require => 'Keywords',
            ValueConv => q{
                my @list = ref $val eq 'ARRAY' ? @$val : ($val);
                foreach (@list) {
                    $_ = lc($_);
                }
                return \@list;
            }
        },
    },
);



then run
"-keywords<lower" "-subject<lower"

PH Edit: Well, not quite "Perfect"... I just spotted a missing closing brace that I have fixed in the config file above.
Title: Re: lowercase keywords
Post by: Phil Harvey on February 22, 2012, 06:40:22 AM
Perfect!
Title: Re: lowercase keywords
Post by: BogdanH on February 22, 2012, 11:07:43 AM
Hi Phil,

I find above script could be usefull in many cases... I didn't try it myself, but can this be used on any tag containing string? Or is it ment only for multi-value tags (like keywords)?
Anyway, would it be possible Exiftool would have such option integrated? Ok, it wouldn't be used that often, but when needed, it would be great if user wouldn't need to start looking after solution... just an idea  :)

Bogdan
Title: Re: lowercase keywords
Post by: Phil Harvey on February 22, 2012, 11:16:47 AM
Hi Bogdan,

The above user-defined tag will work for any type of tag, but for non-list-type tags it is more complicated that necessary because the value will never be an ARRAY reference.

Are you saying you would like an option to convert all tag values to lower case?  I doubt that anyone would ever use this. :P

- Phil
Title: Re: lowercase keywords
Post by: BogdanH on February 22, 2012, 12:24:14 PM
Hi Phil,

No, I don't need such option right now. And that's the point: when (if at all) I will need this option, believe me, I won't know how to do it with Exiftool -I would probably start coding GUI  :)
It was just an idea: script (solution) is allready there, it's short... so I thought, next time you (being busy anyway) wouldn't need to "describe" how to do it  ;)
Nevermind... it really isn't important.. I mean it.

Bogdan