Remove and rename duplicate namespace in exiftool

Started by tgardner, October 17, 2018, 02:19:07 PM

Previous topic - Next topic

tgardner

Hello. I have an issue where my xmp has two of the 'same' namespaces and correlated fields except one namespace has _1_ in its identifier. The one with the _1_ is actually the correct namespace, but i want to fix the identifier to remove the _1_. However, when i try to remove one namespace, it removes the wrong one (i believe because it is removing the first one it comes across but i'm not sure).

Here are the details of what is in the image for these problem namespaces when i view Raw in Adobe Bridge:
xmlns:BLAH_1_="http://ns.myname.com/BLAH/1.0/"
xmlns:BLAH="http://blah.org/schema/1.0"
         <BLAH_1_:EventDate>April 15, 2018</BLAH_1_:EventDate>
         <BLAH_1_:EventLocation>Burbank, USA</BLAH_1_:EventLocation>
         <BLAH:EventDate>April 15, 2018</BLAH:EventDate>
         <BLAH:EventLocation>Burbank, USA</BLAH:EventLocation>

However when i output the xmp with exiftool, it only reports one set of fields not 2. As it sees only one namespace BLAH.

The correct namespace is xmlns:BLAH="http://ns.myname.com/BLAH/1.0/"

So i am trying to remove the second namespace and then remove the _1_ from the first one.

However, after i run this command in exiftool to remove the BLAH namespace exiftool -xmp-BLAH:all= FileOrDir, it is actually removing the _1_ version instead resulting in:

xmlns:BLAH="http://blah.org/schema/1.0"
         <BLAH:EventDate>April 15, 2018</BLAH:EventDate>
         <BLAH:EventLocation>Burbank, USA</BLAH:EventLocation>

Where what i want is to remove the second instance, then rename the first, resulting in:

xmlns:BLAH="http://ns.myname.com/BLAH/1.0/"
         <BLAH:EventDate>April 15, 2018</BLAH:EventDate>
         <BLAH:EventLocation>Burbank, USA</BLAH:EventLocation>

So my question is what command can i first run to remove BLAH (xmlns:BLAH="http://blah.org/schema/1.0") while leaving BLAH_1_ (xmlns:BLAH_1_="http://ns.myname.com/BLAH/1.0/") and then what second command do i run to rename BLAH_1_ and its corresponding fields to just BLAH?

Phil Harvey

I can remove either version without problems.  Here is a Terminal transcript from my Mac:

> cat a.xmp
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1.1-111">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <rdf:Description rdf:about=""
    xmlns:BLAH_1_="http://ns.myname.com/BLAH/1.0/"
    xmlns:BLAH="http://blah.org/schema/1.0">
    <BLAH_1_:EventDate>April 15, 2018 1</BLAH_1_:EventDate>
    <BLAH_1_:EventLocation>Burbank, USA 1</BLAH_1_:EventLocation>
    <BLAH:EventDate>April 15, 2018</BLAH:EventDate>
    <BLAH:EventLocation>Burbank, USA</BLAH:EventLocation>   photoshop:History="">
  </rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end="w"?>

> exiftool a.xmp -xmp-blah:all=
    1 image files updated

> cat a.xmp
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 11.15'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:BLAH_1_='http://ns.myname.com/BLAH/1.0/'>
  <BLAH_1_:EventDate>April 15, 2018 1</BLAH_1_:EventDate>
  <BLAH_1_:EventLocation>Burbank, USA 1</BLAH_1_:EventLocation>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>

> cp a.xmp_original a.xmp

> exiftool a.xmp -xmp-blah_1_:all=
    1 image files updated

> cat a.xmp
<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?>
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='Image::ExifTool 11.15'>
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>

<rdf:Description rdf:about=''
  xmlns:BLAH='http://blah.org/schema/1.0'>
  <BLAH:EventDate>April 15, 2018</BLAH:EventDate>
  <BLAH:EventLocation>Burbank, USA</BLAH:EventLocation>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>
<?xpacket end='w'?>


But it would be difficult to change the namespace prefix after removing the unwanted one.  Changing the namespace prefix should have no effect anyway.

- Phil

P.S. FAQ 3 explains why you weren't seeing both when extracting originally.
...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 ($).

tgardner

Thank you Phil! This appears to be working. I'm not sure why i wasn't getting these results the first time i tried, odd.