ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: email@m-moser.de on January 04, 2013, 05:01:06 AM

Title: how to define multiple conditions for ExifTool?
Post by: email@m-moser.de on January 04, 2013, 05:01:06 AM
I would like to use multiple conditions, e.g.
if "$Model eq 'NIKON D200'"  -> -"Nikon:CameraSerialNumber=6007814'"
if "$Model eq 'DSC-V3'"  -> -"EXIF:CameraSerialNumber=7559435"
if <another condition>  ->  ....

In the command line it is not possible, because all conditions must be true to execute the meta data changes.

Is it possible to add multiple condition statements to the .ExifTool_config file?

How can this be done?  (I am not so familiar with Perl and I did not find an example.)

Thank you very much in advance for your attention,
Manfred
Title: Re: how to define multiple conditions for ExifTool?
Post by: Phil Harvey on January 04, 2013, 07:09:27 AM
Hi Manfred,

You can do this by separating the commands with the -execute option:

exiftool -if "$Model eq 'NIKON D200'"  -Nikon:CameraSerialNumber=6007814 -execute -if "$Model eq 'DSC-V3'"  -EXIF:CameraSerialNumber=7559435 -common_args DIR

The only downside is that the files are parsed for each command.

- Phil

Edit: Added missing "-" to -if
Title: Re: how to define multiple conditions for ExifTool?
Post by: email@m-moser.de on January 06, 2013, 05:00:03 AM
Hi Phil,

I tested multiple -if conditions separated by -execute options on the command line work as you suggest.

BUT I want to use many (> 20) if conditions - so the files are parsed more than 20 times.  This takes too much time for (big) RAW files.

Is there another solution possible? (e.g. if conditions in .ExifTool_config file)

Best regards,
Manfred

 
Title: Re: how to define multiple conditions for ExifTool?
Post by: Phil Harvey on January 06, 2013, 07:35:32 AM
Hi Manfred,

It is a bit more complicated, but this could be done with user-defined tags and a command like this

exiftool "-cameraserialnumber<myserialnumber" DIR

with a config file (https://exiftool.org/config.html) like this:

%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        MySerialNumber => {
            Require => 'Model',
            ValueConv => q{
                return 6007814 if $val eq 'NIKON D200';
                return 7559435 if $val eq 'DSC-V3';
                # ...
                return undef;
            },
        },
    },
);
1; # end


- Phil