News:

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

Main Menu

Ignoring minor error results in unexpected behavior

Started by jeff_k, February 21, 2021, 11:15:03 AM

Previous topic - Next topic

jeff_k

I'm using the config file below to rename & move files in a variety of situations depending on the date, time, and model tags in the files.
When I run it, if it finds a file without a model tag, it notes the error "Warning: [minor] Tag 'model' not defined" but does still properly name (with "Unknown" as the model placeholder in the file name) & move the file.

When I add in the -m option, it runs quietly, but instead of adding "Unknown" to the filename, it simply adds the "- " and leaves a blank model, as though ignoring the error is causing it to go ahead & execute the expression with the model tag - which is null since there's no model tag.

It's not a big deal to see the errors, of course, but I'm wondering whether it's possible still to use the -m option but also not execute the expressions with the model tag included (when there is no model tag, of course).

-r
-if
$filename =~ m/\(JSK\)/
-d
/Volumes/Io/staging/exiftool_testing/4-final/%Y/%Y-%m/%Y-%m-%d at %H-%M-%S
-filename<$filecreatedate - Unknown (JSK)%-c.%e
-filename<$filecreatedate - ${model;s/\//-/} (JSK)%-c.%e
-filename<$createdate - Unknown (JSK)%-c.%e
-filename<$createdate - ${model;s/\//-/} (JSK)%-c.%e
-filename<$datetimeoriginal - Unknown (JSK)%-c.%e
-filename<$datetimeoriginal - ${model;s/\//-/} (JSK)%-c.%e
-filename<$datetimeoriginal.${subsectimeoriginal;$_='0'x(3-length).$_} - Unknown (JSK)%-c.%e
-filename<$datetimeoriginal.${subsectimeoriginal;$_='0'x(3-length).$_} - ${model;s/\//-/} (JSK)%-c.%e
-ext+
AVI
/Volumes/Io/staging/exiftool_testing/9-testing

StarGeek

Just pointing out this is not unexpected behavior.  From the docs on the -m (-ignoreMinorErrors) option
   Note that this causes missing values in -tagsFromFile, -p and -if strings to be set to an empty string rather than an undefined value.

You could try something like adding s/^$/Unknown/ (e.g.  ${model;s/\//-/;s/^$/Unknown/}) to convert an empty string to Unknown.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

jeff_k

<facepalm> missed seeing that in the docs - that's perfect, thanks.