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
(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
The -progress option (https://exiftool.org/exiftool_pod.html#progress-:-TITLE) 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 (https://exiftool.org/exiftool_pod.html#p-FMTFILE-or-STR--printFormat) 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.
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
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 "========".