if Condition issue when combined with if4

Started by fxstein, November 01, 2022, 04:21:21 PM

Previous topic - Next topic

fxstein

Hi,

Chasing a strange phenomenon with tag names in -if when combined with -if4 in the same execution.

Here is an example that works:

exiftool -a -G1 -s -CameraSerialNumber /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4 -if '$GoPro:CameraSerialNumber eq "C3464224512442"'

Output:
[GoPro]         CameraSerialNumber              : C3464224512442

Now when I add an -if4 parameter it stops working:

exiftool -a -G1 -s -CameraSerialNumber /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4 -if '$GoPro:CameraSerialNumber eq "C3464224512442"' -if4 '${FileCreateDate#;DateFmt("%Y%m%d%H%M%S")} ge "20221004" and ${FileCreateDate#;DateFmt("%Y%m%d%H%M%S")} lt "20221030"' -v

Output:
Condition: Use of uninitialized value $info{"GoPro:CameraSerialNumber"} in string eq - /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4
-------- /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4 (failed condition)
    1 files failed condition


I have also tried a simplified version:
exiftool -a -G1 -s -CameraSerialNumber /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4 -if '$GoPro:CameraSerialNumber eq "C3464224512442"' -if4 '1 eq 1' -v

Output:
Condition: Use of uninitialized value $info{"GoPro:CameraSerialNumber"} in string eq - /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4
-------- /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4 (failed condition)
    1 files failed condition


Same issue. The moment any -if4 condition gets added, the -if condition stops working. Same if I switch the order of them.
If you want to help fix GoPro and related EXIF metadata please check out: https://github.com/fxstein/GoProX

StarGeek

The docs on the -if option in regards to the number suffix say
    see the -fast option documentation for details

The appropriate docs on the -fast option (emphasis mine)
     -fast4 doesn't even read the file header, and returns only System tags and a FileType based on the file extension

If you use -if4, you cannot check the condition of an embedded tag as no embedded tags are read.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

fxstein

Thank you! That is all very clear.

If you take another look at the example I provided you will find that the tag check is in a -if check without a NUM.

What the documentation does not seem to spell out is that if you add multiple -if checks they get upgraded (downgrade to the lowest common capability) to the highest NUM

it seems that if you combine -if condition -if4 another-condition both seem to become -if4
If you want to help fix GoPro and related EXIF metadata please check out: https://github.com/fxstein/GoProX

fxstein

#3
But that let me to try another variant with turning -if into -if0 and that works.

exiftool -a -G1 -s -CameraSerialNumber /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4 -if4 '1 eq 1' -if0 '$GoPro:CameraSerialNumber eq "C3464224512442"'

now does what is expected:
[GoPro]         CameraSerialNumber              : C3464224512442

But it only works when the -if4 comes before (to the left) of -if0

Therfore:
exiftool -a -G1 -s -CameraSerialNumber /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4 -if0 '$GoPro:CameraSerialNumber eq "C3464224512442"' -if4 '1 eq 1'

will fail again as before:
Condition: Use of uninitialized value $info{"GoPro:CameraSerialNumber"} in string eq - /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4
-------- /Users/oratzes/goprox-test/processed/MP4/2022/20221011/P_20221011151430_GoPro_Hero10_2442_GX011643.mp4 (failed condition)
    1 files failed condition

If you want to help fix GoPro and related EXIF metadata please check out: https://github.com/fxstein/GoProX

Phil Harvey

You're right, this isn't documented.  I'll fix this.

Currently, multiple -if conditions are all evaluated at once at the level (ie. NUM) of the last -if option which includes a NUM.

I should change this so they use the lowest NUM.

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

fxstein

Is there any way to keep both?

Run the -if4 first and only load extra data for matches. That way you get the speed benefit from -if4 and only incur the cost of -if0 when needed.Since they are AND together, that would be a viable choice.
If you want to help fix GoPro and related EXIF metadata please check out: https://github.com/fxstein/GoProX

Phil Harvey

Adding a potential separate pass for each -if option would complicate the code a lot, and I don't think it would be worth the cost since I doubt anyone else would ever take advantage of this feature.

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