how to define multiple conditions for ExifTool?

Started by email@m-moser.de, January 04, 2013, 05:01:06 AM

Previous topic - Next topic

email@m-moser.de

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

Phil Harvey

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

email@m-moser.de

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

 

Phil Harvey

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