Set a "prefix" or "leading text" before an existing label.

Started by yevev35775, October 16, 2021, 03:21:49 PM

Previous topic - Next topic

yevev35775

I want to "prefix" the label that ExifTool writes out to a textfile.

This command is working;

exiftool -s -s -w! txt -ImageWidth -ImageHeight -r -ext jpg "pix"

It gives (for example) this output into a text-file like "IMG_20211016_150135.txt";

ImageWidth: 3840
ImageHeight: 2160


But I want to get this output (mention the prefix before the label);

camera__ImageWidth: 3840
camera__ImageHeight: 2160





It is possible to prefix ALL labels with a string like "camera__"?




Reason : I am creating sidecards for about 10.000 photo's, and the meta-data is fetched and rendered by a .php script on a webserver.

The server fetches only ".yaml" files with keys that are prefixed by "camera__".

Of course I can replace the cards line by line using another script, but maybe it's build into ExitTool?

StarGeek

You can't change the tag names by default, but you can control the output using the -p (-printFormat) option.

If you're only listing a few tags, you could do this, assuming Windows CMD, swap double/single quotes to prevent bash interpretation of the dollar signs.
exiftool -p "camera__ImageWidth: $ImageWidth$/camera__ImageHeight: $ImageHeight" /path/to/files/

If you have a lot of tags, you would be better off using a format file, as described in the above link.
* 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).

yevev35775

Thank you - this work perfectly.

I indeed want to control the output to a separate text-file, I don't to write to the image itself.

So when I have this image foo.jpg, I want to create a text-file called foo.txt with all the meta-data.

Using the following command, I can control the output (or key / value pairs, in .YAML language);

exiftool -s -s -w! txt -p "camera__file : $FileName$/camera__date : $CreateDate$/camera__shutter : $ShutterSpeed$/camera__width : $ImageWidth$/camera__height : $ImageHeight" -r -ext jpg "pix"

The above code fetches every .jpg image inside a folder (and it's subfolders), write (and overwrites) a text-file with all the tags mentioned, prefixed by "camera__" and a new line for every entry.

camera__file : IMG_20210913_151255.jpg
camera__date : 2021:09:13 15:12:55
camera__shutter : 1/1053
camera__width : 3840
camera__height : 2160


I do get some warning from the prompt, like;

Warning: [minor] Unrecognized MakerNotes - pix/folder-B/IMG_20210913_104711.jpg

But it does work :-)

--

Windows 10 / most recent version of ExifTool