remove (sort of) duplicate tags...

Started by themanwho, January 08, 2011, 04:57:50 PM

Previous topic - Next topic

themanwho

Hi!
I am stuck with some questionable XMP that contains pairs of tags that differ in case only, for example XMP-tiff:make and XMP-tiff:Make.  I would like to remove them both and write them back with the proper case.  A single call to $exiftool->SetNewValue ( 'make' => undef ); or $exiftool->SetNewValue ( 'Make' => undef ); removes only the first instance -- regardless of case.  What I wound up doing is something like:


        $exiftool->SetNewValue ( 'make' => undef );
        $exiftool->WriteInfo ( $source );
        $exiftool->SetNewValue ( 'make' => undef );
        $exiftool->WriteInfo ( $source );

which successfully removes both.  This seems a little awkward though, and I suspect there my be a better way to do it?  I have also tried:

        $exiftool->SetNewValue ( 'make' => [undef,undef] );

and again, it removes only the first occurring instance.

Is there a more idiomatic way of accomplishing my goal?

Thanks in Advance,
Bill


Phil Harvey

Hi Bill,

Would I be correct in assuming that the questionable XMP was written by a Microsoft product?  They have an absolutely terrible track record when it comes to using the wrong case for XMP tags, and I have already added a patch to ExifTool specifically to prevent the exact type of problem you are seeing now.

Unfortunately I can't think of any way to coax ExifTool to remove two tags when only one may be specified.  It would require yet another patch to handle this type of peculiar file, and since this is the first time I have heard of this problem, and the work-around isn't really too painful, I don't think the patch is worthwhile in this case.

- Phil

P.S. BTW, you can remove the 2nd call to SetNewValue() since the settings are preserved through WriteInfo() calls.
...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 ($).

themanwho

Well, I'm not sure --  I was handed this collection of images rather blindly, but it wouldn't surprise me if you are correct.

No problem here, so long as I can get the job done one way or another.  Thanks for the heads-up on removing one line of code anyway.  I will try simply:


        $exiftool->SetNewValue ( 'make' => undef );
        $exiftool->WriteInfo ( $source );
        $exiftool->WriteInfo ( $source );

correct?

Thanks a million,
Bill

Phil Harvey

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