Inconsistent output with 1 vs. multiple files, *.ext and -ext

Started by Marsu42, August 01, 2023, 05:31:15 PM

Previous topic - Next topic

Marsu42

I've written several batch scripts parsing the output of exiftool.

(At least on Windows), there is a inconsistentcy when parsing 1 vs. multiple files

Odd behavior: With 1 file and *.ext there is no output of the "======== " line with the filenname
Expected behavior: The "======== " line is there no matter what, how many files, *.ext or -ext ext

Result: My scripts relying on parsing the "======== " line to get the respective filename fail (I cannot simply use -ext dng .\ because actually it's patterns like *_EXP?.dng).

To reproduce...

... 1 file, exiftool -Aperture *.dng => odd/inconsistent because of missing "======== " line
Aperture: 2.2
... 1 file, exiftool -Aperture -ext dng .\
======== ./20230401_123456.dng
Aperture: 2.2

... multipe files, exiftool -Aperture *.dng
======== 20230401_123456.dng
Aperture: 2.2
======== 20230401_987654.dng
Aperture: 2.2

... multipe files,exiftool -Aperture -ext dng .\
======== ./20230401_123456.dng
Aperture: 2.2
======== ./20230401_987654.dng
Aperture: 2.2

Neal Krawetz

(Others can correct me if I'm wrong.)

By default, ExifTool only shows the filename separator ("======= filename") if there are multiple files.

If you want to always see it, then fake it by supplying a non-existing second file.

exiftool *.dng "" 2>/dev/null
Where there are multiple files, the output ends with a summary of the number of files. Using this approach, there will always be two summary lines:
    1 image files read
    1 files could not be read

StarGeek

The -progress option will also force the separator, though with it you then have to take note of the counter at the end of the line
C:\>exiftool -G1 -a -s -progress -filename y:\!temp\Test4.jpg
======== y:/!temp/Test4.jpg [1/1]
[System]        FileName                        : Test4.jpg

The -p (-printFormat) option also allows the output to be listed in any format desired, though it would require explicitly listing any tags you want to extract.

This behavior has been how exiftool has operated for nearly 20 years and is extremely unlikely to changes as doing so could break innumerable scripts.
* 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

I don't see this as inconsistent.  The O/S expands *.dng on the command line, so if there is only 1 dng then ExifTool sees this as a single file on the command line.  I don't want the "======" line output if you just type one file on the command line.

Either use -ext or StarGeek's -progress suggestion or add a dummy file like Neal suggested if you need the "======" line for a single file.

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

Marsu42

Quote from: Phil Harvey on August 03, 2023, 07:23:06 AMEither use -ext or StarGeek's -progress suggestion or add a dummy file like Neal suggested if you need the "======" line for a single file.- Phil

Thanks a lot for your answers, these workarounds are just fine!

The progress option adds another [x/n] indicator behind the file name, so I'm using the dummy file without changing the script detection for the file name after the "========".