ExifTool Forum

ExifTool => Newbies => Topic started by: KKP44 on May 14, 2018, 06:47:35 AM

Title: Batch creating XMP files with a custom schema
Post by: KKP44 on May 14, 2018, 06:47:35 AM
Hello everyone!

I have to create about 22k XMP files with a custom metadata schema:

<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 10.76'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<rdf:Description rdf:about=''
  xmlns:dc='http://purl.org/dc/elements/1.1/'>
  <dc:creator>
   <rdf:Seq>
    <rdf:li>CompanyName</rdf:li>
   </rdf:Seq>
  </dc:creator>
  <dc:date>
   <rdf:Seq>
    <rdf:li>DATE</rdf:li>
   </rdf:Seq>
  </dc:date>
  <dc:description>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'>Canon EOS 5D Mk II</rdf:li>
   </rdf:Alt>
  </dc:description>
  <dc:format>FORMAT</dc:format>
  <dc:identifier>ID</dc:identifier>
  <dc:relation>
   <rdf:Bag>
    <rdf:li>RELATION</rdf:li>
   </rdf:Bag>
  </dc:relation>
  <dc:title>
   <rdf:Alt>
    <rdf:li xml:lang='x-default'>TITLE[/b]</rdf:li>
   </rdf:Alt>
  </dc:title>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:exif='http://ns.adobe.com/exif/1.0/'>
  <exif:ColorSpace>65535</exif:ColorSpace>
  <exif:PixelXDimension>X</exif:PixelXDimension>
  <exif:PixelYDimension>Y</exif:PixelYDimension>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:photoshop='http://ns.adobe.com/photoshop/1.0/'>
  <photoshop:AuthorsPosition>AUTHOR</photoshop:AuthorsPosition>
  <photoshop:CaptionWriter>EOS Utility</photoshop:CaptionWriter>
  <photoshop:DateCreated>2017</photoshop:DateCreated>
  <photoshop:ICCProfile>Grayscale</photoshop:ICCProfile>
  <photoshop:Source>SRC</photoshop:Source>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:tiff='http://ns.adobe.com/tiff/1.0/'>
  <tiff:Compression>34712</tiff:Compression>
  <tiff:Orientation>1</tiff:Orientation>
  <tiff:XResolution>300/1</tiff:XResolution>
  <tiff:YResolution>300/1</tiff:YResolution>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:xmp='http://ns.adobe.com/xap/1.0/'>
  <xmp:CreateDate>2017-00-04T20:01:00+02:00</xmp:CreateDate>
  <xmp:CreatorTool>EOS Utility</xmp:CreatorTool>
  <xmp:MetadataDate>2017-01-00T21:08:42+02:00</xmp:MetadataDate>
  <xmp:ModifyDate>2017-01-00T21:08:42+02:00</xmp:ModifyDate>
</rdf:Description>

<rdf:Description rdf:about=''
  xmlns:xmpMM='http://ns.adobe.com/xap/1.0/mm/'>
  <xmpMM:DocumentID>xmp.did:94F1C8F1F119E211AF95D98E08D7F076</xmpMM:DocumentID>
  <xmpMM:InstanceID>xmp.iid:95F1C8F1F119E211AF95D98E08D7F076</xmpMM:InstanceID>
  <xmpMM:OriginalDocumentID>xmp.did:94F1C8F1F119E211AF95D98E08D7F076</xmpMM:OriginalDocumentID>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>

The tags in bold vary from file to file and folder the image is currently in. I found out how to batch create/write xmp files but I have to manually open each and every file and change the bolded values so they match the data. Is there any way to speed this process up?
Title: Re: Batch creating XMP files with a custom schema
Post by: Phil Harvey on May 14, 2018, 07:22:43 AM
Two questions:

1. I only see standard XMP tags here.  What is the custom schema you mention?

2. When you say "change the bolded values so they match the data", what exactly do you mean?  Specifically, what data?  If the "data" is extractable with ExifTool from this or some other like-named file, then you can copy it over using the exiftool -tagsfromfile feature.

- Phil
Title: Re: Batch creating XMP files with a custom schema
Post by: KKP44 on May 14, 2018, 07:44:31 AM
1. I must have mixed up the terms, I'm pretty new to this.

I'll explain a little bit in detail:

I'm currently scanning publications, each page must have it's separate .jp2 image and this image has to have the xmp embedded into it. Each publication released in a given year has 10-40 volumes.

<rdf:li>DATE</rdf:li>

This tag must match the date the material was published. 1999, 2001 etc

<dc:format>FORMAT</dc:format>

This tag contains the data about the volume and pages in the current publication  in this format:

vol 1, nr 40, 8 p

The next  one will be

vol 1, nr 41, 16 p

etc

<dc:identifier>ID</dc:identifier>

This tag cointains the picture filename 
id-221_vol-1_nr-40_scn-001 (scn-002 etc)
id-221_vol-1_nr-41_scn-001 (scn-002 etc)


<rdf:li>RELATION</rdf:li>

This tag contains the PDF file the picture is linked to: id-221_vol-1_nr-40.pdf

And of course every picture has it's own resolution but the exiftool reads that automatically.

So my question is: Is there any way to automate the process of updating the metadata so it corresponds to it's file and publication?

Right now I'm opening each and every file and changing these values by hand. That wouldn't be a problem but I have to do it for 22k pages.


Title: Re: Batch creating XMP files with a custom schema
Post by: Phil Harvey on May 14, 2018, 08:28:00 AM
To automate this, ExifTool must be able to read the publish date, etc from somewhere.  Where does this information come from (digitally)?

- Phil
Title: Re: Batch creating XMP files with a custom schema
Post by: KKP44 on May 14, 2018, 08:33:05 AM
The date is in the folder  and file name, the pdf file is in a subfolder and the information for the dc:format field has to be done by hand because it varies.
Title: Re: Batch creating XMP files with a custom schema
Post by: Phil Harvey on May 14, 2018, 09:17:28 AM
You should be able to automate this for the date at least.  For dc:format, automation won't be possible unless you create a CSV file or something like that to get the data from.  You can create a blank CVS like this:

exiftool -csv -f -Format DIR > out.csv

then edit out.csv to fill in the desired Format and use it to write the Format back to the files:

exiftool -csv=out.csv DIR

If you give me specific examples about the directory and file names, I can show you how to set dc:date.

- Phil