Skip to main content
lfcorullon13651490
Legend
June 21, 2022
Answered

[SCRIPT] Get multiple authors from linkXmp

  • June 21, 2022
  • 3 replies
  • 1299 views

I'm trying to get the property Author from linkXmp.

This is how it shows in Links panel.

The result is only "tanleimages".
But the expected result is "tanleimages, Elenamiv/Shutterstock" as it is showing in Links panel (or Bridge, or Photoshop). Why I can't get the correct information using "linkXmp.author"? Any idea? Thanks in advance.

This topic has been closed for replies.
Correct answer Kasyan Servetsky

How about this workaround?

var doc = app.activeDocument;

main();

function main() {
	var link = doc.links[0],
	linkXmp = link.linkXmp,
	arr = [],
	count = 1,
	result;
	
	while (result != "") {
		result = linkXmp.getProperty("http://purl.org/dc/elements/1.1/", "creator/*[" + count + "]");
		if (result != "") arr.push(result);
		count++;
	}
}

3 replies

Kasyan Servetsky
Kasyan ServetskyCorrect answer
Legend
June 22, 2022

How about this workaround?

var doc = app.activeDocument;

main();

function main() {
	var link = doc.links[0],
	linkXmp = link.linkXmp,
	arr = [],
	count = 1,
	result;
	
	while (result != "") {
		result = linkXmp.getProperty("http://purl.org/dc/elements/1.1/", "creator/*[" + count + "]");
		if (result != "") arr.push(result);
		count++;
	}
}

lfcorullon13651490
Legend
June 22, 2022

Awesome!!! Thank you so much, @Kasyan Servetsky!

Legend
June 22, 2022

Have a look at Links panel flyout >> Utilities >> XMP File Info ... >> Raw Data

Is there anything unusual, especially in the photoshop:Credit field? Language attribute, multiple elements?

You could also try the ExtendScript ExternalObject('lib:AdobeXMPScript') instead of the InDesign object. 

Haven't looked at it in years since I'm using an own plug-in to access metadata, but that lib should still be around in the default installation.

lfcorullon13651490
Legend
June 22, 2022

Everything is as usual in File Info window.

 

In Raw Data, the semicolon separated text are shown as list elements.

 

I tried some examples I found using ExternalObject library, but no sucess.

Only a weird one, that doesn't fill my gap using something like:

xm.getProperty(XMPConst.NS_DC , "creator/*[1]") and xm.getProperty(XMPConst.NS_DC , "creator/*[2]")
But, since I don't know the number of elements, I can't get the correct result.

It's weird, because the Caption feature in InDesign, returns the full text (as shown in links panel).

Legend
June 22, 2022
I found some old snippet, see below, if it works you could turn the result into XML() and continue from there.
xmp.serialize( XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT)
rob day
Community Expert
Community Expert
June 21, 2022

Looks like a bug—same thing happens with the ID documnent info when there is either a comma or semicolon delimiter

 

$.writeln(app.activeDocument.metadataPreferences.author)

 

lfcorullon13651490
Legend
June 21, 2022

Thanks for answering.

Uhmm. So this is a known issue and no solution is provided yet?