EndDir() Unexpected result

Started by JlrJlr, October 02, 2020, 05:11:14 PM

Previous topic - Next topic

JlrJlr

Hello

My first post here. I am a frequent reader of this forum where, because of the excellent quality of the post answers, I find most answers to my own questions and ideas on usage of Exiftool and good practice of meta data. Exiftool is a fantastic tool to manage metas of my photos. Thanks Phil.

What I am trying to do is to get a list of directories where at least one photo has no "By-line". For now I am just interested in directories no the individual photos. I came across the EndDir() function that stops scanning a directory as soon as one photo is found. It can save quite some time.

Usage of EndDir() gives some time surprising result that is produced by the following test case.

This case is made of 3 directories each with 3 photos. One dir has AllByline photos, a second has NoByline photos and third is Mixed.


Here is the result of " if  By-line exists", without usage of EndDir())

exiftool -ver -r -By-line -FileName -Directory  -if "$By-line"   -ext jpg \ExifTool\atrt
12.02
======== ExifTool/atrt/AllByLine/_DSCN2350_jlr.JPG
By-line                         : JLR
File Name                       : _DSCN2350_jlr.JPG
Directory                       : ExifTool/atrt/AllByLine
======== ExifTool/atrt/AllByLine/_DSCN2351_jlr.JPG
By-line                         : JLR
File Name                       : _DSCN2351_jlr.JPG
Directory                       : ExifTool/atrt/AllByLine
======== ExifTool/atrt/AllByLine/_DSCN2352_jlr.JPG
By-line                         : JLR
File Name                       : _DSCN2352_jlr.JPG
Directory                       : ExifTool/atrt/AllByLine
======== ExifTool/atrt/Mixed/_DSCN2350_jlr.JPG
By-line                         : JLR
File Name                       : _DSCN2350_jlr.JPG
Directory                       : ExifTool/atrt/Mixed
======== ExifTool/atrt/Mixed/_DSCN2351_jlr.JPG
By-line                         : JLR
File Name                       : _DSCN2351_jlr.JPG
Directory                       : ExifTool/atrt/Mixed
    4 directories scanned
    5 files failed condition
    5 image files read




Now adding usage of EndDir(). This produces unexpected result.

exiftool -ver -r -By-line -FileName -Directory  -if "$By-line and EndDir()"   -ext jpg \ExifTool\atrt
12.02
======== ExifTool/atrt/AllByLine/_DSCN2350_jlr.JPG
By-line                         : JLR
File Name                       : _DSCN2350_jlr.JPG
Directory                       : /ExifTool/atrt/AllByLine

EndDir called - /ExifTool/atrt/AllByLine/_DSCN2350_jlr.JPG
EndDir called - /ExifTool/atrt/Mixed/Pano4120-21.jpg
EndDir called - /ExifTool/atrt/NoByLine/Pano4120-21.jpg
    4 directories scanned
    2 files failed condition
    1 image files read

The 2 last lines of EndDir are unexpeted to me.

Is there something wrong the way I use EndDir() ?

1 Mixed directory, there are 2 files with By-line : _DSCN2350_jlr.JPG and _DSCN2351_jlr.JPG
Why the tags of one of the 2 files is not reported ?
Why the log line shows "Pano4120-21" that as no By-line ?

2 NoByLine directory, but no photo in this directory has By-line
Why is this line displayed ?


Note that using "if not.." gives the expected result when using EndDir.

exiftool -ver -r -By-line -FileName -Directory  -if "not $By-line and EndDir()"   -ext jpg \ExifTool\atrt
12.02
======== /ExifTool/atrt/Mixed/Pano4120-21.jpg
File Name                       : Pano4120-21.jpg
Directory                       : /ExifTool/atrt/Mixed
EndDir called - /ExifTool/atrt/Mixed/Pano4120-21.jpg
======== /ExifTool/atrt/NoByLine/Pano4120-21.jpg
File Name                       : Pano4120-21.jpg
Directory                       : /ExifTool/atrt/NoByLine
EndDir called - /ExifTool/atrt/NoByLine/Pano4120-21.jpg
    4 directories scanned
    3 files failed condition
    2 image files read



Thanks for an answer .

ps I just saw version 12.7 available, I used it but did not notice any difference
pps for clarity the directories has been shorten

Phil Harvey

EndDir stops processing the current subdirectory, not the top-level directory.

If you want to stop processing all directories, use End() instead of EndDir().

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

JlrJlr

Thanks for your quick answer.

"EndDir stops processing the current subdirectory"

That is exactly what I want.

I expect  that, after ending a sub-directory, the others sub-directories are scanned.

This is what has been done since there are 2 enddir lines for the 2 other sub-directories.

EndDir called - /ExifTool/atrt/Mixed/Pano4120-21.jpg
EndDir called - /ExifTool/atrt/NoByLine/Pano4120-21.jpg

The issue is the content of these lines that is not  expected

On line "EndDir called - /ExifTool/atrt/Mixed/Pano4120-21.jpg"
The Mixed directory contains 2 files with By-line : _DSCN2350_jlr.JPG and _DSCN2351_jlr.JPG
-Why the log line shows "Pano4120-21" that has no By-line.
  It should be _DSCN2350_jlr.JPG or_DSCN2351_jlr.JPG
-Why the tags (By-line, File Name, Directory) of one of the 2 files are not reported above the EndDir line ?

On line "EndDir called - /ExifTool/atrt/NoByLine/Pano4120-21.jpg"
The NoByLine directory has only files  without By-line
-Why is this line displayed ?

The expected behavior is obtained in this run where the condition is "-if not ..."

exiftool -ver -r -By-line -FileName -Directory  -if "not $By-line and EndDir()"   -ext jpg \ExifTool\atrt
12.02
======== /ExifTool/atrt/Mixed/Pano4120-21.jpg
File Name                       : Pano4120-21.jpg
Directory                       : /ExifTool/atrt/Mixed
EndDir called - /ExifTool/atrt/Mixed/Pano4120-21.jpg
======== /ExifTool/atrt/NoByLine/Pano4120-21.jpg
File Name                       : Pano4120-21.jpg
Directory                       : /ExifTool/atrt/NoByLine
EndDir called - /ExifTool/atrt/NoByLine/Pano4120-21.jpg
    4 directories scanned
    3 files failed condition
    2 image files read


Thank for your patience. My initial post was probably too long and a bit cryptic (as you can guess English is not my native language).