How to separete keyword- from subject-values

Started by ast, August 31, 2017, 11:31:43 AM

Previous topic - Next topic

ast

In a workflow I read metainformations of a pdf-file via ($exifTool->ExtractInfo($file);) in a form, where users can edit the values. With a second perl-script I write these changed values back to the file.
That works fine with the exception, that subject-values appear in keyword-tags and keyword-values in subject-tags, although I write the new values explizite to each tag.
Is there a way to separete that, so that keyword-tags only have keyword-values and subject-tags only have subject-values?

StarGeek

You'll have to do some research to see what tags you're actually reading and writing.  Use exiftool -a -G1 -s so that you can see tags with duplicate names and the groups they belong to.  With PDFs, it can be doubly confusing if you're checking the info with Adobe Reader as there are three tags called Subject.  XMP-pdf:Subject and PDF:Subject are string tags and hold a description of the PDF.  I believe that Adobe Reader displays these as Subject.  Then there's XMP-dc:Subject, which holds keywords, which Adobe Reader combines with XMP-pdf:Keywords. Just for more fun, there is also PDF:Keywords tag.

A quick test shows that if you're using exiftool to do something like -subject=This is the subject.", then the phrase is written to both PDF:Subject (the description tag) and XMP-dc:Subject (the keywords tag). 

I'd suggest you be more explicit with the tag you're writing to. 
* 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).

ast

#2
That exactly is my problem. I write to subject and it appears in keywords and my question is how to avoid this.
I have to edit both Keywords and Subject

$exifTool->SetNewValue($tag[$i], \@keywords, Replace => 1);   
$exifTool->SetNewValue($tag[$i], $file_beschreibung, Replace => 1);   

The values are replaced right, but I am looking for a way to avoid the concatenation of both values.

I am using ExifToolVersion : 9.13

ast

I now found, that I have to clear all XMP-Tags

my @data = ("Author","Keywords","ModifyDate","Rights","Title","Subject");
my $elemente = @data;

for ($i=0; $i<$elemente; $i++)
{
    if ($i==1)
   {
       if (my $tagname =~ m/^XMP-.*:$data[$i]/)
       {
          $exifTool->SetNewValue($tagname=>'', Group => 'XMP');
       }
       $exifTool->SetNewValue($data[$i]=>\@keywords, Group => 'PDF');
   }
   if ($i==5)
   {
       my $tagname = "XMP-dc:".$data[$i];
       $exifTool->SetNewValue($tagname=>'', Group => 'XMP');
       $exifTool->SetNewValue($data[$i]=>$file_beschreibung, Group => 'PDF');
   }
}

This works fine