Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects › Retrieve aeProjectLink from XMP data with Extendscript

  • Retrieve aeProjectLink from XMP data with Extendscript

    Posted by Dan Racusin on December 4, 2019 at 11:11 pm

    Please help! I am trying to get this path stored as a string /Users/dracusin/Desktop/CollectorTestProject.aep

    This is from the files XMP. I can see the line in bridge(vie FileInfo) but not in the AE metadata panel.

    Here is my current function:


    function GetMetaData(){
    var item = app.project.activeItem;
    var selectedFile = new File($.fileName);
    var itemPath = selectedFile.parent.fsName;
    var filePath = itemPath + "/" + item.name;
    var fileRef = new File(filePath);

    if (fileRef instanceof File) {
    if (ExternalObject.AdobeXMPScript == undefined) {
    ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
    }
    var xmpFile = new XMPFile(filePath, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_READ);
    var xmp = xmpFile.getXMP();
    var newXML = xmp.getProperty(XMPConst.NS_CREATOR_ATOM, 'fullPath');
    alert("Error: " + newXML);
    xmpFile.closeFile();
    }
    }

    This line returns the correct data for some reason:
    var newXML = xmp.getProperty(XMPConst.NS_XMP, ‘CreateDate’).toString();
    2019-11-27T19:49:44Z

    This line does not:
    var newXML = xmp.getProperty(XMPConst.NS_CREATOR_ATOM, ‘fullPath’);
    /Users/dracusin/Desktop/TestProject.aep

    Any ideas?

    Dan Racusin replied 6 years, 9 months ago 2 Members · 2 Replies
  • 2 Replies
  • Walter Soyka

    December 5, 2019 at 2:53 pm

    I couldn’t figure out the clean way to do this — NS_CREATOR_ATOM doesn’t seem to be a registered namespace — so here’s a hacky code fragment to do it instead:

    var xmpFile = new XMPFile(filePath, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_READ);
    var xmp = xmpFile.getXMP();

    // take the whole XMP object and make it into a string so we can parse it manually
    var xmpString = xmp.dumpObject().toString();

    // use a regular expression to find the fullPath item of the aeProjectLink struct of the creatorAtom
    var creatorFsName = xmpString.match(RegExp('(.*creatorAtom:fullPath = ")(.*)(")'))[2];

    alert(creatorFsName);

    You should add some error checking to this, because as written, it will fail hard if there’s no project link data.

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Dan Racusin

    December 6, 2019 at 6:22 am

    Thank you Walter! This works perfect for what I need. I was so excited when this worked I jumped out of my seat.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy