ExifTool Forum

ExifTool => Newbies => Topic started by: JoniR on June 01, 2014, 12:36:59 PM

Title: Multiple if-conditions and adding keywords [SOLVED]
Post by: JoniR on June 01, 2014, 12:36:59 PM
Hi,
I am looking way to adding multiple if-conditions and then add multiple keywords based on metadata.
For now I have created .ExifTool_config like this:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MyModel => {
            Require => 'Model',
            ValueConv => q{
                return ["canon","eos","50d"] if $val eq 'Canon EOS 50D';
return ["canon","eos","1100d"] if $val eq 'Canon EOS 1100D';
                # ...
                return undef;
            },
        },
MyLensModel => {
            Require => 'LensModel',
            ValueConv => q{
                return ["tamron","1750mm","vc"] if $val eq '17-50mm';
return ["ef50mmf18ii","canonef50mmf18ii","50mm"] if $val eq 'EF50mm f/1.8 II';
return ["sigma","70-300mm"] if $val eq '70-300mm';
                # ...
                return undef;
            },
        },
    },
);
1; # end


And then running ExifToolexiftool "-keywords+<MyModel" "-keywords+<MyLensModel" 1.jpg my image is only getting keywords from MyLensModel.
If I am running this two times like this:

exiftool "-keywords+<MyModel" 1.jpg
exiftool "-keywords+<MyLensModel" 1.jpg

my image is getting keywords correctly from both MyModel and MyLensModel as well.

Do I miss some fundamental thing here or what is the problem?
Title: Re: Multiple if-conditions and adding keywords
Post by: Phil Harvey on June 01, 2014, 02:00:06 PM
This is mentioned in the -tagsFromFile documentation (see note 5).  You want to use -addTagsFromFile instead of the implied -tagsFromFile.

- Phil
Title: Re: Multiple if-conditions and adding keywords [SOLVED]
Post by: JoniR on June 01, 2014, 02:08:25 PM
Thank you very much for fast response.
If someone is struggling with same problem, solution is simple like Phil stated.
exiftool -addtagsfromfile @ "-keywords+<MyModel" "-keywords+<MyLensModel" 1.jpg

-Joni