Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 135144

Re: adding name of indesign document to metadata of all images used in document

$
0
0

This should should give you a start. It'll add the active documents name to the field instructions of the img when executed. Tested once. No errorhandling.

 currDoc = app.activeDocument;
 docName = currDoc.name;
 docGraphics = currDoc.allGraphics;

for(var g = 0; g < docGraphics.length; g++){    currGraphic = docGraphics[g];        currGraphicFilePath = currGraphic.itemLink.filePath;        fileObject = File(currGraphicFilePath);
writeDocNameToMeta(fileObject, docName);    }

function writeDocNameToMeta(fileObject, docName){
if(loadXMPLibrary()){
        var myFile = fileObject;        xmpFile = new XMPFile(myFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);        var myXmp = xmpFile.getXMP();              var myStatus = myXmp.getProperty(XMPConst.NS_PHOTOSHOP,"Instructions");   myXmp.deleteProperty(XMPConst.NS_PHOTOSHOP, "Instructions");   myXmp.setProperty(XMPConst.NS_PHOTOSHOP, "Instructions", docName);      if (xmpFile.canPutXMP(myXmp)) {          xmpFile.putXMP(myXmp);    }             xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);        unloadXMPLibrary();    }
}    function loadXMPLibrary(){        if ( !ExternalObject.AdobeXMPScript ){            try{ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');}            catch (e){alert('Unable to load the AdobeXMPScript library!'); return false;}        }        return true;    }

function unloadXMPLibrary(){
        if( ExternalObject.AdobeXMPScript ){            try{ExternalObject.AdobeXMPScript.unload(); ExternalObject.AdobeXMPScript = undefined;}            catch (e){alert('Unable to unload the AdobeXMPScript library!');}        }    }

Hans-Gerd Claßen


Viewing all articles
Browse latest Browse all 135144

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>