Copy link to clipboard
Copied
I have various text anchors with given as variables. I am able to alert the object information of variables in an illustrator document using the script below. Is there a way of copying the contents of those into the metadata? I don't mind which field of metadata. Thanks.
var idoc = app.activeDocument; | |
var vars = idoc.variables; | |
for (j=0; j<vars.length; j++) | |
alert(vars |
Copy link to clipboard
Copied
You can reference below:
Extend_Script_experimentals/XMPtool.jsx at master · ten-A/Extend_Script_experimentals · GitHub
Copy link to clipboard
Copied
To clarify, I would like to write to the metadata form the variable object data in the file, not write the metadata to an exported file.
Copy link to clipboard
Copied
You can use it to write opened document metadata.
To set custom metadata and get opened document path(ex: XMPtool.f = app.activeDocument.fullName).
Call the write function with previouse path.
Copy link to clipboard
Copied
Thanks for your help, but sorry, I don't follow at all. Why are we talking about previous paths? Could you specify the script which would enable me to write to the keywords metadata? I've tried with the GitHub script and it isn't doing anything.
Copy link to clipboard
Copied
Try it:
XMPtool = {
ns : "http://ns.example.com/metawrite/1.0/", //You shuld rewrite your own Name Space.
prefix : "Vriable:", //You can set your prefix
f : new Object(),
read : function(prop){
if(xmpLib==undefined) var xmpLib = new ExternalObject('lib:AdobeXMPScript');
var xmpFile = new XMPFile(this.f.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
var xmpPackets = xmpFile.getXMP();
var xmp = new XMPMeta(xmpPackets.serialize());
alert(xmp.getProperty(this.ns, prop).toString());
},
write : function(prop, val){ //f:fileObject, arg1:String, arg2:String
if(xmpLib==undefined) var xmpLib = new ExternalObject('lib:AdobeXMPScript');
var xmpFile = new XMPFile(this.f.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var xmp = xmpFile.getXMP();
var mt = new XMPMeta(xmp.serialize());
XMPMeta.registerNamespace(this.ns, this.prefix);
mt.setProperty(this.ns, prop, val);
if (xmpFile.canPutXMP(xmp)) xmpFile.putXMP(mt);
xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
}
//If you want write into activeDocument, Set activeDocuments fullName property like below.
XMPtool.f = app.activeDocument.fullName;
XMPtool.write("key1", "Your value");
XMPtool.read("key1");
Find more inspiration, events, and resources on the new Adobe Community
Explore Now