Skip to main content
wckdtall
Inspiring
Jan 30, 2025 10:21 PM UTC
Answered

Illustrator - Read XMP Title

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>

 

sttk3Correct answer
Legend
Jan 31, 2025 3:23 AM UTC

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

7 replies

sttk3Correct answer
Legend
Jan 31, 2025 3:23 AM UTC

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

Translate
wckdtall
wckdtallAuthor
Inspiring
Jan 31, 2025 7:16 AM UTC

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.

Translate
Legend
Jan 31, 2025 8:54 AM UTC

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

Translate
Charu Rajput
Community Expert
Community Expert
Jan 30, 2025 11:45 PM UTC

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");
}

 

Translate
Best regards
wckdtall
wckdtallAuthor
Inspiring
Jan 31, 2025 2:29 AM UTC

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,

 

Translate