ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: Martin B. on January 22, 2024, 09:44:12 AM

Title: Prepend the file name on each output line
Post by: Martin B. on January 22, 2024, 09:44:12 AM
Hi,

Is there a way to get an output like this (note the file name at the beginning of each line):
IMG_0001.JPG:Canon Camera Info Unknown 0x0000: -86
IMG_0001.JPG:Canon Camera Info Unknown 0x0001: -69
IMG_0001.JPG:Canon Camera Info Unknown 0x0002: 0
...
IMG_0001.JPG:Canon Shot Info 0x000b          : 8
IMG_0001.JPG:Canon Shot Info 0x000c          : 154
...
IMG_0002.JPG:Canon Camera Info Unknown 0x0000: -43
IMG_0002.JPG:Canon Camera Info Unknown 0x0001: -11
IMG_0002.JPG:Canon Camera Info Unknown 0x0002: 0
...
IMG_0002.JPG:Canon Shot Info 0x000b          : 7
IMG_0002.JPG:Canon Shot Info 0x000c          : 152
etc.

from a command like this:
exiftool -U "-Canon_CameraInfoUnknown_*" "-Canon_shotinfo_*" "-Canon_fileinfo_*" "-Canon_CMP1_*" "-Canon_IAD1_*" .

I tried the -tab option, but this option is to get one line per file, whereas I need as many lines per file as the number of tags that ExifTool finds.

Right now, I post process the output of exiftool -w out/%f_%e.txt with grep Canon * > all_results.txt to get all results in a single file, but my instinct tells me there's an easier way.

Thanks!
Title: Re: Prepend the file name on each output line
Post by: StarGeek on January 22, 2024, 10:22:58 AM
Offhand, I don't think so.

The -p (-printFormat) option (https://exiftool.org/exiftool_pod.html#p-FMTFILE-or-STR--printFormat) gives a lot of flexibility in formatting the output, but it doesn't allow the use of wildcards when listing tag names. You have to specify each tag you want to list individually and would fail if the tag doesn't exist unless the -m (-ignoreMinorErrors) option (https://exiftool.org/exiftool_pod.html#m--ignoreMinorErrors)/-f (-ForcePrint) option (https://exiftool.org/exiftool_pod.html#f--forcePrint) is used.
Title: Re: Prepend the file name on each output line
Post by: Martin B. on January 22, 2024, 10:48:17 AM
Thanks StarGeek. I had also looked at the -p option and came to the same conclusion.