Suppression of warning messages but not of error messages

Started by timitalia, February 10, 2022, 04:29:47 AM

Previous topic - Next topic

timitalia

Context: When executing a move command, e.g. like:

exiftool -r -d %Y-%m-%d '-directory<${CreatedDate#;DateFmt("%Y")}/${make;}/$createdate' .


I receive two kinds of messages: "already exists (at target destination)" errors and "Tag 'XYZ' not defined" warnings:

Error: '/Users/MyUserName/PICTURES/target/2021/Apple/2021-10-31/IMG_E9818.JPG' already exists - ./IMG_E9818.JPG
Warning: [minor] Tag 'CreatedDate' not defined - ./IMG_2992.HEIC


All fine, now my question:

Is there a way to suppress only the "Tag 'XYZ' not defined" warnings or generally all warnings but still display the ("already exists") errors? So no warnings only errors. I found -m, but it seems to suppress both warnings and errors.

Thank you very much for your hint,
Cheers Tim

Phil Harvey

Hi Tim,

The -m option ignores "[minor]" warnings, and downgrades "[minor]" errors to a warning.  Other errors and warnings are not affected.  The "already exists" error is not minor.

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

StarGeek

Also, in case you missed Note #1 under the -TAG[+-^]=[VALUE] option, you can use another tag to fall back upon in case your main tag is missing.  Using your example, you could fall back on FileModifyDate, which always exists, if CreateDate doesn't exist.
exiftool -r -d %Y-%m-%d  '-directory<${FileModifyDate#;DateFmt("%Y")}/${make;}/$FileModifyDate' '-directory<${CreatedDate#;DateFmt("%Y")}/${make;}/$createdate' .
* 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).

Phil Harvey

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

StarGeek

Quote from: Phil Harvey on February 10, 2022, 10:18:08 AM
Also note that "CreatedDate" will never exist.

It does now!  Hah, checkmate!
%Image::ExifTool::UserDefined = (
    'Image::ExifTool::Composite' => {
        CreatedDate => {
Require => 'CreateDate',
ValueConv => ValueConv => '$val',
},
},
);


Seriously though, I missed that.
* 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).

Phil Harvey

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

timitalia

Thanks a lot for your replies!
However, I may have a special case with the -m option here. With me it behaves with the following script like this:


exiftool -r -if \

'$FileType ne "XMP" &&

$FileType ne "AAE"' \

-m -ee -d %Y-%m-%d \

'-directory<'$targetdir'/${ModifyDate#;DateFmt("%Y")}/${make;}/$ModifyDate' \

'-directory<'$targetdir'/${DateTimeOriginal#;DateFmt("%Y")}/${make;}/$DateTimeOriginal' \

'-directory<'$targetdir'/${CreateDate#;DateFmt("%Y")}/${make;}/$createdate' \

'-directory<'$targetdir'/${CreatedDate#;DateFmt("%Y")}/${make;}/$CreatedDate' \

.



Starting situation:
- SourceDir/IMG_XYZ.JPG
- TargetDir/ (empty)

After running the script:
- SourceDir/ (empty)
- TargetDir/2021/Apple/2021-01-01/IMG_XYZ.JPG

Everything is as expected.

But if I now copy IMG_XYZ.JPG back to the SourceDir and excecute it a second time:
- SourceDir/ (empty)
- TargetDir
   - /2021/Apple/2021-01-01/IMG_XYZ.JPG
   - /Apple/2021-01-01/IMG_XYZ.JPG

So it ignored the YYYY Subfolder and moved it again, to a new destination, into TargetDir/Apple/2021-01-01/IMG_XYZ.JPG.

Third round:
Only now, (after the image is already in the two destinations inside TargetDir), if I copy the Image back to the SourceDir and run the script for the third time, I get the expected message and the image is not moved

- Error: '/TargetDir/2021/Apple/2021-01-01/IMG_XYZ.JG' already exists - ./IMG_XYZ.JG.JPG

The strange thing:
Without the -m option I cannot reproduce this, so without -m the Image (as desired) does not get moved no matter how many times I execute - I receive the error message if it already exists in TargetDir/2021/Apple/2021-01-01/IMG_XYZ.JPG


Again my motivation for using -m: Suppression of warning messages but not of error messages
Operating System: Mac

Cheers Tim



timitalia

By the way, you may wonder why I have four times this line with different tags in the script above


-directory<'$targetdir'/${ModifyDate#;DateFmt("%Y")}/${make;}/$ModifyDate'
-directory<'$targetdir'/${DateTimeOriginal#;DateFmt("%Y")}/${make;}/$DateTimeOriginal' 
-directory<'$targetdir'/${CreateDate#;DateFmt("%Y")}/${make;}/$createdate'   
-directory<'$targetdir'/${CreatedDate#;DateFmt("%Y")}/${make;}/$CreatedDate'


As I have had many different camera models, some quite old snapshot models over the years, I can't always be sure that CreateDate is present in the exit data, so I hope at least one of these other tags is present: ModifyDate, DateTimeOriginal or CreatedDate

This is my approach I do not know if there is a better way

timitalia

#8
Quote from: StarGeek on February 10, 2022, 09:57:07 AM
Also, in case you missed Note #1 under the -TAG[+-^]=[VALUE] option, you can use another tag to fall back upon in case your main tag is missing.  Using your example, you could fall back on FileModifyDate, which always exists, if CreateDate doesn't exist.
exiftool -r -d %Y-%m-%d  '-directory<${FileModifyDate#;DateFmt("%Y")}/${make;}/$FileModifyDate' '-directory<${CreatedDate#;DateFmt("%Y")}/${make;}/$createdate' .

Who can read is at an advantage, I overlooked your comment:  Thank you StarGeek!
So you basically saying FileModifyDate is enough as a fallback for CreateDateand I don't need ModifyDate, DateTimeOriginal, and CreatedDate ?!

Phil Harvey

You can't use the -m option with a command like this because ignoring the missing tag warning causes empty values to be inserted for missing tags in the string.

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

StarGeek

Quote from: timitalia on February 11, 2022, 03:22:09 AM
'$FileType ne "XMP" && $FileType ne "AAE" '

Instead of doing this, I would suggest using the -ext (-extension) option to exclude those file types.  Using
--ext xmp --ext aee
means that exiftool will skip those files completely.

And to add to Phil's comment, 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
* 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).

timitalia