Copy link to clipboard
Copied
I need to get the Author of the image through scripting. First i have to get the name of the Author which is already existing.And need to Rename the Author through script. Its urgent requiremnt. pls help me out.
Copy link to clipboard
Copied
This example will read and put the Authors name to the ESTK console and write the new details back to the document.
#target bridge
loadXMPLibrary();
var thumb = app.document.selections[0];
if(thumb.hasMetadata){
var selectedFile = thumb.spec;
var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
var myXmp = myXmpFile.getXMP();
var arrItem='';
var items = myXmp.countArrayItems(XMPConst.NS_DC, "creator");
for(var i = 1;i <= items;i++){
arrItem += myXmp.getArrayItem(XMPConst.NS_DC, "creator", i);
}
$.writeln(arrItem);
}
var Author = "This is my new Author";
myXmp.deleteProperty(XMPConst.NS_DC, "creator");
myXmp.appendArrayItem(XMPConst.NS_DC, "creator", Author, 0,XMPConst.ARRAY_IS_ORDERED);
if (myXmpFile.canPutXMP(myXmp)) {
myXmpFile.putXMP(myXmp);
myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
}
unloadXMPLibrary();
function loadXMPLib(){
if (ExternalObject.AdobeXMPScript == undefined) {
ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
}
}
function unloadXMPLib(){
if( ExternalObject.AdobeXMPScript ) {
try{
ExternalObject.AdobeXMPScript.unload();
ExternalObject.AdobeXMPScript = undefined;
}catch (e){ }
}
}