ExifTool Forum

ExifTool => Newbies => Topic started by: jnm21 on December 19, 2014, 07:42:38 PM

Title: Copying items stored in CDATA
Post by: jnm21 on December 19, 2014, 07:42:38 PM
Hello Phil, I have been tinkering with ExifTool the past few weeks and it is fantastic. Thank you for it.

I have had small successes tinkering and creating new .arg files, but I'm stuck on one thing. I am trying to convert many old XMP files that I have inherited which have many different tags, several which are proprietary, and convert them to IPTC standard tags. I have created a .arg file that properly translates all of the other tags except for the dc:description. The dc:description contains six lines of data that is different between each XMP file, and I'm trying to convert it to -IPTC:Caption-Abstract.

Here is the snippet I am having trouble with:

  <rdf:RDF>
    <rdf:Description rdf:about="filename">
        <dc:creator>
          <rdf:Seq>
            <rdf:li>photographer name</rdf:li>
          </rdf:Seq>
        </dc:creator>
        <dc:description>
          <rdf:Alt>
            <rdf:li xml:lang="x-default"><![CDATA[
line 1
line 2
line 3
line 4
line 5
line 6

]]></rdf:li>
          </rdf:Alt>
        </dc:description>
  </rdf:RDF>

I've been able to successfully convert the dc:creator tag to the -IPTC:By-line, but not the dc:description tag. I am only able to get line 1 of the data copied to -IPTC:Caption-Abstract. I have been searching the forums and the web for info as I believe it is the CDATA, but I am not sure. Is there a way to get lines 1 through 6 to copy as well?

Thank you,
Jordan
Title: Re: Copying items stored in CDATA
Post by: Phil Harvey on December 20, 2014, 10:00:16 AM
Hi Jordan,

I can't remember anyone ever doing this before so I will have to try it myself to see what happens.  I should be able to find time later today to play with this.  I'll post back afterwards and let you know if have a way for you to accomplish this.

- Phil
Title: Re: Copying items stored in CDATA
Post by: Phil Harvey on December 20, 2014, 10:19:43 AM
OK, I gave it a quick try.  I get this after preparing a file (a.jpg) containing your XMP:

> exiftool a.jpg -description -b

line 1
line 2
line 3
line 4
line 5
line 6
> exiftool a.jpg "-caption-abstract<description"
    1 image files updated
> exiftool a.jpg -caption-abstract -b

line 1
line 2
line 3
line 4
line 5
line 6


So it copies everything fine as far as I can tell.  Perhaps the newlines are causing you problems.  You can translate them using an advance formatting expression if you want (see the documentation for how to do this).  The expression to translate newlines would look somthing like this: tr/\n/x/ (where "x" is what you want to translate them to)

- Phil
Title: Re: Copying items stored in CDATA
Post by: jnm21 on December 22, 2014, 04:10:36 PM
Hi Phil, thank you for your reply. So far I have been unsuccessful solve the issue with the method you described, but I believe I may have made a mistake in properly describing the issue. In my initial post, I copied code from a code editor I was using to look at the XMP file. But I just used ExifTool to display the XMP file using the command "exiftool -a testfile.xmp" and it gave this for the dc:description field:

..line 1..line 2..line 3..line 4..line 5..line 6..

So does mean the new lines/character returns are actually seen as double periods to Exiftool? What would be the best method to translate them properly?

I apologize for the elementary question, I am new to Exiftool and I greatly appreciate your help.

Thank you,
Jordan
Title: Re: Copying items stored in CDATA
Post by: StarGeek on December 23, 2014, 01:38:53 AM
Quote from: jnm21 on December 22, 2014, 04:10:36 PM
So does mean the new lines/character returns are actually seen as double periods to Exiftool?

Control characters such as Line Feeds are replaced by periods by default.  If you're getting double periods, you probably have a Carriage Return/Line Feed sequence.  You might take a look at the -b (http://www.exiftool.org/exiftool_pod.html#b) option to see if that gives you the output you're looking for.

Whenever I'm not quite sure what the exact characters are in a tag, I'll often add the -php (http://www.exiftool.org/exiftool_pod.html#php) option as well.  It will list the tag in a php notation, where characters such as the carriage return and line feed will show up as \r and \n.