Conflict between what is displayed and what is interpreted by '-if'

Started by warzauwynn, September 07, 2017, 08:41:50 PM

Previous topic - Next topic

warzauwynn


$ exiftool -ver
10.10
$ lsb_release -d
Description:    Ubuntu 16.04.3 LTS
$ perl --version | grep x86
This is perl 5, version 22, subversion 1 (v5.22.1) built for x86_64-linux-gnu-thread-multi


While attempting to sort movies based on their length I discovered inconsistencies between comparisons when using '-if' vs what is being displayed when just displaying output. Here is are some examples of what I am seeing. All files are movies taken with the default iPhone camera, but not necessarily the same model of iPhone or same iOS software version.


$ exiftool -n -p '${Filename}: ${Duration#}' 20170827-11-18-40.mov
20170827-11-18-40.mov: 126.66
$ exiftool -n -v '-TestName<CreateDate' -if '${Duration#} gt 13' 20170827-11-18-40.mov
-------- 20170827-11-18-40.mov (failed condition)
    1 files failed condition
$ exiftool -n -v '-TestName<CreateDate' -if '${Duration#} gt 12' 20170827-11-18-40.mov
======== 20170827-11-18-40.mov
Setting new values from 20170827-11-18-40.mov
'20170827-11-18-40.mov' --> '2017:08:27 11:18:40'
    0 image files updated
    1 image files unchanged


It looked like Exiftool may be shifting a decimal when doing the comparison with '-if'...


$ exiftool -n -p '${Filename}: ${Duration#}' 20170808-08-12-22.mov
20170808-08-12-22.mov: 113.765
$ exiftool -n -v '-TestName<CreateDate' -if '${Duration#} gt 12' 20170808-08-12-22.mov
-------- 20170808-08-12-22.mov (failed condition)
    1 files failed condition
$ exiftool -n -v '-TestName<CreateDate' -if '${Duration#} gt 11' 20170808-08-12-22.mov
======== 20170808-08-12-22.mov
Setting new values from 20170808-08-12-22.mov
'20170808-08-12-22.mov' --> '2017:08:08 08:12:22'
    0 image files updated
    1 image files unchanged


But further inspection makes it seem like something more complicated...


$ exiftool -n -p '${Filename}: ${Duration#}' 20170809-14-33-12.mov
20170809-14-33-12.mov: 93.7683333333333
$ exiftool -n -v '-TestName<CreateDate' -if '${Duration#} gt 93' 20170809-14-33-12.mov
======== 20170809-14-33-12.mov
Setting new values from 20170809-14-33-12.mov
'20170809-14-33-12.mov' --> '2017:08:09 14:33:12'
    0 image files updated
    1 image files unchanged
$ exiftool -n -v '-TestName<CreateDate' -if '${Duration#} gt 94' 20170809-14-33-12.mov
-------- 20170809-14-33-12.mov (failed condition)
    1 files failed condition
$ exiftool -n -v '-TestName<CreateDate' -if '${Duration#} gt 99' 20170809-14-33-12.mov
-------- 20170809-14-33-12.mov (failed condition)
    1 files failed condition
$ exiftool -n -v '-TestName<CreateDate' -if '${Duration#} gt 100' 20170809-14-33-12.mov
======== 20170809-14-33-12.mov
Setting new values from 20170809-14-33-12.mov
'20170809-14-33-12.mov' --> '2017:08:09 14:33:12'
    0 image files updated
    1 image files unchanged


Revisiting the first video file and looping through 150 comparisons shows this:


$ exiftool -n -p '${Filename}: ${Duration#}' 20170827-11-18-40.mov
20170827-11-18-40.mov: 126.66
$ for X in {0..150} ; do exiftool -n -v '-TestName<CreateDate' -if '${Duration#} gt '"$X" 20170827-11-18-40.mov > /dev/null && echo "Passed $X" || echo "Failed $X" ; done ;
Passed 0
Passed 1
Failed 2
Failed 3
Failed 4
Failed 5
Failed 6
Failed 7
Failed 8
Failed 9
Passed 10
Passed 11
Passed 12
Failed 13
...continued failures...
Failed 99
Passed 100
...continued passes...
Passed 126
Failed 127
...continued failures...
Failed 150

StarGeek

I didn't read all the way through your post, but noticed a mistake right off, because I have made it myself.

gt is a string comparison.  In such a case, 126.66 is greater than 12, but still less than 13.

For numerical comparisons, use >, <, etc.
* 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).

warzauwynn

Good catch! That was the problem. Thanks!