Skip to main content
wckdtall
Inspiring
January 30, 2025
Answered

Illustrator - Read XMP Title

  • January 30, 2025
  • 2 replies
  • 948 views

I'm trying to figure out how to read the XMP Title of a document, and compare it to the file name. I keep coming up empty on google, and their AI is recommending a function that doesn't exist as per usual.

From what I'm seeing in the scripting documents, there is only:
app.activeDocument.XMPString

How do I just parse out the title? I keep getting results for Photoshop and InDesign, but those functions don't appear to cross over into Illustrator.

<dc:title>
<rdf:Alt>
<rdf:li xml:lang="x-default">Untitled-2</rdf:li>
</rdf:Alt>
</dc:title>

 

Correct answer sttk3

To add another solution, AdobeXMPScript makes it easy to parse.

2 replies

sttk3Correct answer
Legend
January 31, 2025

To add another solution, AdobeXMPScript makes it easy to parse.

wckdtall
wckdtallAuthor
Inspiring
January 31, 2025

Thanks! Works like a charm! I don't know if I'd say it's easy, but I can't really wrap my mind around xmp, cause it always seems to be a diffrent formatted xml, and use different functions between all the programs.

Is there a straight forward guide you've come across that explains it? I guess since most of extendscript is a single package, once it gets into different libraries, it's a stumbling block every time for me.

Legend
January 31, 2025

See Scripting Access to XMP Metadata in JavaScript Tools Guide CC.pdf.

Charu Rajput
Community Expert
Community Expert
January 30, 2025

Hi @wckdtall,

To get the title you can directly read using the following

app.activeDocument.name

but still if you required to get the title from the document XMP, please try

var regex = /<rdf:li[^>]*xml:lang="x-default"[^>]*>(.*?)<\/rdf:li>/;
var match = app.activeDocument.XMPString.match(regex);
if (match && match[1]) {
    var title = match[1];
    alert("Title found : " + title);
} else {
    alert("Title not found");
}

 

Best regards
wckdtall
wckdtallAuthor
Inspiring
January 31, 2025

Thanks! I'll give this regex a shot. Do you know if the xml markup is the same for all filetypes? Eps, pdf, ai etc?


Are there any other functions built in  to get/set properties? Love the idea of regex for this since I was just asking to read, just wondering if I'll need additional lookarounds.

 

Like the idea of regex since I only have to read at this point,