This example will create two folder and move all Photoshop EPS files into one folder and all others to the second folder.
All EPS files in the current folder are targeted.
#target bridge
if( BridgeTalk.appName == "bridge" ) {
sortEPS = MenuElement.create("command", "Sort EPS Files", "at the end of Tools","eps");
}
sortEPS.onSelect = function () {
//deselect any selected files
app.document.deselectAll();
//select all eps files
var thumbs= app.document.getSelection("eps");
if(!thumbs.length) return; //No eps files
if (ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
//create two folders to seperate eps files
var nonPSeps = new Folder(app.document.presentationPath+ '/Non Photoshop EPS');
if(!nonPSeps.exists) nonPSeps.create();
var PSeps = new Folder(app.document.presentationPath+ '/Photoshop EPS');
if(!PSeps.exists) PSeps.create();
//Iterate through all eps files
for(var a in thumbs){
//get metadata in read mode
var xmpf = new XMPFile(thumbs.spec.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
var xmp = xmpf.getXMP();
//Check if "CreatorTool" field has data
if( xmp.doesPropertyExist(XMPConst.NS_XMP, "CreatorTool" ) ) {
//get CreatorTool information
var CreatorTool = xmp.getProperty(XMPConst.NS_XMP, "CreatorTool" ).toString();
if(CreatorTool.match("Photoshop")) {
//Photoshop eps file
thumbs.moveTo(PSeps);
}else{
//Non Photoshop eps file
thumbs.moveTo(nonPSeps);
}
}else{
//no xmp move to non Photoshop
thumbs.moveTo(nonPSeps);
}
}//end thumbs
};