EndDir unexpected behaviour

Started by JlrJlr, October 05, 2020, 12:20:55 PM

Previous topic - Next topic

JlrJlr

This post is the follow-up of original post EndDir() Unexpected result.

I have sharpen the test case and activated the -v1 option to understand when the misbehavior occurs. I did that as an exercise to practice Exiftool and I hope that this small contribution can help  to make exifTool even better

Briefly EndDir misbehaves on sub-folders read after the first sub folder where the if condition is true and thus EndDir has operated.

The test case is made of 5 sub-folders each containing one or two files with or without the tag "By-line". The name of sub-directories and some files are prefixed by a number to control the order of treatment. Probels occurs on sub-folders 02 and 03.

The ref test case without using EndDir().

exiftool -v1  -r -By-line -FileName -Directory  -if "$By-line"   -ext jpg .

-------- ./00NoByLine/NoByLine_01.jpg (failed condition)

======== ./01AllByLine/ByLine_jlr.jpg
By-line                         : JLR
File Name                       : ByLine_jlr.jpg
Directory                       : ./01AllByLine

-------- ./02Mixed/0_NoByLine_01.jpg (failed condition)
======== ./02Mixed/1_ByLine_jlr.jpg
By-line                         : JLR
File Name                       : 1_ByLine_jlr.jpg
Directory                       : ./02Mixed

-------- ./03NoByLine/NoByLine_01.jpg (failed condition)

======== ./04AllByLine/ByLine_jlr.jpg
By-line                         : JLR
File Name                       : ByLine_jlr.jpg
Directory                       : ./04AllByLine
    6 directories scanned
    3 files failed condition
    3 image files read


The test with EndDir().

exiftool -v1  -r -By-line -FileName -Directory  -if "$By-line  and EndDir()"   -ext jpg .

-------- ./00NoByLine/NoByLine_01.jpg (failed condition)

======== ./01AllByLine/ByLine_jlr.jpg
By-line                         : JLR
File Name                       : ByLine_jlr.jpg
Directory                       : ./01AllByLine
EndDir called - ./01AllByLine/ByLine_jlr.jpg

-------- ./02Mixed/0_NoByLine_01.jpg (failed condition)
EndDir called - ./02Mixed/0_NoByLine_01.jpg

-------- ./03NoByLine/NoByLine_01.jpg (failed condition)
EndDir called - ./03NoByLine/NoByLine_01.jpg

======== ./04AllByLine/ByLine_jlr.jpg
By-line                         : JLR
File Name                       : ByLine_jlr.jpg
Directory                       : ./04AllByLine
EndDir called - ./04AllByLine/ByLine_jlr.jpg

    6 directories scanned
    3 files failed condition
    2 image files read


Comment on resuts :


:) 00NoByLine = (failed condition) EndDir not called : that is expected

:) 01AllByLine = (Condition triggered) EndDir called : that is expected

- 02Mixed contains 2 files one without "By-line" the other with (in this order)

-------- ./02Mixed/0_NoByLine_01.jpg (failed condition)
======== ./02Mixed/1_ByLine_jlr.jpg
By-line                         : JLR
File Name                       : 1_ByLine_jlr.jpg
Directory                       : ./02Mixed


Result

-------- ./02Mixed/0_NoByLine_01.jpg (failed condition)
EndDir called - ./02Mixed/0_NoByLine_01.jpg

:o The scan of subdirectory "02Mixed" call EndDir on first file and missed the second that meets the condition.



03NoByLine contains 1 file without "By-line"


-------- ./03NoByLine/NoByLine_01.jpg (failed condition)

Result

-------- ./03NoByLine/NoByLine_01.jpg (failed condition)
EndDir called - ./03NoByLine/NoByLine_01.jpg


:o The scan of subdirectory "03NoByLine" calls EndDir on a file that fails the condition.

note that EndDir is ok on 00NoByLine (not called). 03NoByLine is identical to 00NoByLine except that it is treated after
01AllByLine that has called EndDir.

Test done with

ExifTool version 12.07
Perl version 5.024000 (-C0)
Platform: MSWin32
Optional libraries:
  Archive::Zip                 1.47
  Compress::Zlib               2.069
  Digest::MD5                  2.54
  Digest::SHA                  5.95
  IO::Compress::Bzip2          2.069
  Time::Piece                  1.31
  Unicode::LineBreak           (not installed)
  IO::Compress::RawDeflate     2.069
  IO::Uncompress::RawInflate   2.069
  Win32::API                   0.84
  Win32::FindFile              0.15
  Win32API::File               0.1203





Phil Harvey

Right.  Thanks!  Good catch!

You're right.  This will be fixed in ExifTool 12.08.

(Sorry for the delay in responding, but I had to find time to set up the files to reproduce this problem.)

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

Phil Harvey

This brings up a question:  If EndDir() is called while processing files in a directory, what happens to subdirectories of that directory?  Do they still get processed?  Or does it depend on the order in which the directory was listed?  Since the order is problematic, I would think it would make sense to just stop processing files in the directory and continue to process subdirectories if the -r option is used.

- 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 answer, I am glad I could help making exiftool better than best.

Quote from: Phil Harvey on October 07, 2020, 07:45:28 PM
This brings up a question:  If EndDir() is called while processing files in a directory, what happens to subdirectories of that directory?  Do they still get processed?  Or does it depend on the order in which the directory was listed?  Since the order is problematic, I would think it would make sense to just stop processing files in the directory and continue to process subdirectories if the -r option is used.

In this case, for my usage, your propoal is what I am expecting : stop processing the directory with a message and continue drilling into the sub sub directories.

JlrJlr

Phil, thanks a lot for V12.08 it solves perfectly this small issue.

Phil Harvey

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

Phil Harvey

Ooops.  I haven't yet implemented the continuing to drill into subdirectories.  It will only do this currently if the subdirectory is processed before the file that resulted in the EndDir() call.  I'll do this in the next release.

- 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

Just tested EndDir with ExifTool 12.09 in case of sub sub dir : it works smoothly.

Many thanks for this perfect job.