• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Illustrator - Read XMP Title

Enthusiast ,
Jan 30, 2025 Jan 30, 2025

Copy link to clipboard

Copied

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>

 

TOPICS
How-to , Scripting

Views

186

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Jan 30, 2025 Jan 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");
}

 

Votes

Translate

Translate
Community Expert , Jan 30, 2025 Jan 30, 2025

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

Votes

Translate

Translate
Adobe
Community Expert ,
Jan 30, 2025 Jan 30, 2025

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 30, 2025 Jan 30, 2025

Copy link to clipboard

Copied

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,

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 30, 2025 Jan 30, 2025

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 30, 2025 Jan 30, 2025

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2025 Jan 31, 2025

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Jan 31, 2025 Jan 31, 2025

Copy link to clipboard

Copied

Thanks! Looks like this documentation doesn't have an example with Illustrator's XMPString, your example is clear on how to handle. XMPString is the equivalent to xmpMetadata.rawData in photoshop.

 

//Photoshop example
var xmp = new XMPMeta(app.activeDocument.xmpMetadata.rawData);

//Illustrator example
var xmp = new XMPMeta(app.activeDocument.XMPString);

 


After the library is loaded, looks like all is needed to read the title directly is:

var xmp = new XMPMeta(app.activeDocument.XMPString);
alert(xmp.getLocalizedText(XMPConst.NS_DC,"title", null, null));

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 31, 2025 Jan 31, 2025

Copy link to clipboard

Copied

LATEST

Illustrator's XMPString is an Illustrator feature, see Illustrator JavaScript Scripting Reference.pdf.

 

If you want to use the exact same process in Illustrator, Photoshop, or another app, you can get the XMP string directly from the file via XMPFile. This can be found in the JavaScript Tools Guide.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines