For files with matching value , return only the matching "child" element values

Started by jamesgrace, October 11, 2021, 10:08:08 AM

Previous topic - Next topic

jamesgrace

Greetings !

I've spent a fair amount of time searching the forum - so , I apologize in advance if this has already been previously answered :

Example XML :

<xmpTPg:Fonts>
   <rdf:Bag>
   
      <rdf:li rdf:parseType="Resource">
         <stFnt:fontFileName>MyriadPro-Regular.otf</stFnt:fontFileName>
         <stFnt:fontName>MyriadPro-Regular</stFnt:fontName>
         <stFnt:fontType>OpenTypeCFF</stFnt:fontType>
      </rdf:li>

      <rdf:li rdf:parseType="Resource">
         <stFnt:fontFileName>Times.dfont</stFnt:fontFileName>
         <stFnt:fontName>Times-Roman</stFnt:fontName>
         <stFnt:fontType>TrueType</stFnt:fontType>
      </rdf:li>

   </rdf:Bag>
</xmpTPg:Fonts>



The following ( macOS ) example locates all files that may contain TrueType fonts - but , the output includes all "fontname" and "fontfilename" values ( even for element values that may not have a matching "fonttype" ) :


exiftool -T -m -directory -filename -fontname -fontfilename -r -if '$FontType =~ /TrueType/' "/EXAMPLE/Jobs Archive" > Jobs_with_TrueType_Fonts.txt


Is it somehow possible , to return only the "fontname" and "fontfilename" child/sub element values for only the matching "fonttype" element values ?




StarGeek

I'm no expert with XML, but I'm believe those are "sibling" elements, not "child" elements, though I could be wrong.

I don't think exiftool can do this, but again, I may be wrong.  Phil or someone more knowledgeable about XML will have to answer.

You may need a more XML or XPATH oriented solution.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

Phil Harvey

This could be done with a user-defined tag by parsing the Fonts structure returned by the -struct option.  I don't have time to show you how to do this at the moment, but I can help later if necessary.

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