FORUMS: list search recent posts

Retrieve aeProjectLink from XMP data with Extendscript

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
dan racusin
Retrieve aeProjectLink from XMP data with Extendscript
on Dec 4, 2019 at 11:11:56 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?


Return to posts index

Walter Soyka
Re: Retrieve aeProjectLink from XMP data with Extendscript
on Dec 5, 2019 at 2:53:58 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 [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

dan racusin
Re: Retrieve aeProjectLink from XMP data with Extendscript
on Dec 6, 2019 at 6:22:25 am

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


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 CreativeCOW.net All Rights Reserved
[TOP]