ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Jan.Steinman on February 20, 2024, 11:56:45 PM

Title: How to default command line options with .ExifTool_config?
Post by: Jan.Steinman on February 20, 2024, 11:56:45 PM
I've been through the documents (https://exiftool.org/config.html, https://exiftool.org/ExifTool.html#Options), and I still don't understand how to change command line options via the .ExifTool_config file.

Specifically, I want -ignoreMinorErrors, -overwrite_original_in_place†, -preserve, and -recurse turned on as the default.

Is this possible? Or should I just make a shell alias with those options enabled?

Thanks!

† I use hard links a lot, so I need to make sure that exifTool doesn't break those links.
Title: Re: How to default command line options with .ExifTool_config?
Post by: StarGeek on February 21, 2024, 01:13:13 AM
The options listed under Options (https://exiftool.org/ExifTool.html#Options) can be set as shown at the bottom of the example config file.  As far as I can recall, other command line options don't have a way to set as default, though Phil may correct me on that.

From your list, it looks like only IgnoreMinorErrors (https://exiftool.org/ExifTool.html#IgnoreMinorErrors) can be set by the config file.  You would do so like this

%Image::ExifTool::UserDefined::Options = (
    IgnoreMinorErrors=> 1,
);

Edit: Previous post from Phil, most likely applies to your other options as well
Quote from: Phil Harvey on July 04, 2019, 11:05:16 AMUnfortunately -overwrite_original is an application-level option only.  It doesn't have an equivalent API option that you can set via the config file.
Title: Re: How to default command line options with .ExifTool_config?
Post by: Phil Harvey on February 21, 2024, 06:48:25 AM
Quote from: StarGeek on February 21, 2024, 01:13:13 AMAs far as I can recall, other command line options don't have a way to set as default

Correct.

But I'll look into adding this capability to the config file.

- Phil
Title: Re: How to default command line options with .ExifTool_config?
Post by: Phil Harvey on February 22, 2024, 08:59:07 AM
It turns out that this was easy to implement.  This feature will appear in version 12.78, allowing you to set user-defined command-line arguments like this in the config file:

# Specify default exiftool command-line arguments
# (inserted before all other options except -config)
@Image::ExifTool::UserDefined::Arguments = (
'-echo', '**** Using my default arguments ****',
'-ignoreMinorErrors',
'-overwrite_original_in_place',
'-preserve',
'-recurse',
);

Note that these user-defined arguments will be inserted first on the command line (but after the -config option if used), which means that they will only apply to the first execute'd command if the -execute option is used.  Edit: I thought it made more sense to apply to all execute'd commands, so I have changed it to work this way instead.

Personally, I'm going to use this new feature to ignore files with names starting with ".":

@Image::ExifTool::UserDefined::Arguments = (
'-i', 'HIDDEN',
);

- Phil