Author Topic: How to separete keyword- from subject-values  (Read 1982 times)

ast

  • Newbie
  • *
  • Posts: 3
How to separete keyword- from subject-values
« on: August 31, 2017, 11:31:43 AM »
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

  • Global Moderator
  • ExifTool Freak
  • *****
  • Posts: 2838
Re: How to separete keyword- from subject-values
« Reply #1 on: August 31, 2017, 05:43:47 PM »
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. 
Troubleshooting hints:
* When posting, include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).
* Double all percent signs (%) in a Windows batch file.
* If your GPS coords are negative, make sure and set the GpsLatitudeRef and GpsLongitudeRef tags correctly.

ast

  • Newbie
  • *
  • Posts: 3
Re: How to separete keyword- from subject-values
« Reply #2 on: September 04, 2017, 03:41:53 AM »
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
« Last Edit: September 04, 2017, 04:14:43 AM by ast »

ast

  • Newbie
  • *
  • Posts: 3
Re: How to separete keyword- from subject-values
« Reply #3 on: September 05, 2017, 05:21:46 AM »
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