ExifTool Perl Library Module: How to separate keyword- from subject-values

141 views Asked by At

I am using ExifToolVersion : 9.13 to read out metainformations of a pdf-file to formfields, 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.

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

$exifTool->SetNewValue($data[$i]=>\@keywords, Group0 => 'PDF');
$exifTool->SetNewValue($data[$i]=>$file_beschreibung, Group0 => 'PDF');

I tried to write an empty value to the XMP tags, but that doesn't work

$exifTool->SetNewValue($data[$i]=>$leer, Group0 => 'XMP');

Is there a way to to avoid the concatenation of both values?

1

There are 1 answers

0
ast On

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. Thank you for helping!