News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Multiple if-conditions and adding keywords [SOLVED]

Started by JoniR, June 01, 2014, 12:36:59 PM

Previous topic - Next topic

JoniR

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?

Phil Harvey

This is mentioned in the -tagsFromFile documentation (see note 5).  You want to use -addTagsFromFile instead of the implied -tagsFromFile.

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

JoniR

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