Author Topic: Multiple if-conditions and adding keywords [SOLVED]  (Read 1486 times)

JoniR

  • Newbie
  • *
  • Posts: 2
Multiple if-conditions and adding keywords [SOLVED]
« 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:
Code: [Select]
%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 ExifTool
Code: [Select]
exiftool "-keywords+<MyModel" "-keywords+<MyLensModel" 1.jpg my image is only getting keywords from MyLensModel.
If I am running this two times like this:
Code: [Select]
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?
« Last Edit: June 01, 2014, 02:06:52 PM by JoniR »

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 16877
    • ExifTool Home Page
Re: Multiple if-conditions and adding keywords
« Reply #1 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
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

JoniR

  • Newbie
  • *
  • Posts: 2
Re: Multiple if-conditions and adding keywords [SOLVED]
« Reply #2 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.
Code: [Select]
exiftool -addtagsfromfile @ "-keywords+<MyModel" "-keywords+<MyLensModel" 1.jpg
-Joni