Check if action file exists before running Photoshop action
The Bridge script loads the image stack into into Photoshop layered PSD file. Runs a Photoshop action and saves the file in the same location.
I am trying to check if the action file existe before running the Photoshop action.
The try catch statement did not work. Is the an alternative way of checking if the Photoshop action file exists?
#target bridge
//Saves Br stack as layered PSD file on same location
var stacks = app.document.stacks;
var stackCount = stacks.length;
for(var s = 0;s<stackCount;s++){
var stackFiles = getStackFiles( stacks );
if(stackFiles.length> 1){
var bt = new BridgeTalk;
bt.target = "photoshop";
var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+stackFiles.toSource()+");");
bt.body = myScript;
bt.send(5);
}
}
function getStackFiles( stack ){
var files = new Array();
for( var f = 0; f<stack.thumbnails.length;f++){
files.push(stack.thumbnails
}
return files;
};
function psRemote(stackFiles){
app.bringToFront();
var thisDoc = open(File(stackFiles[0]));
var Name = decodeURI(app.activeDocument.name).slice(0,-4);
thisDoc.layers[0].name = decodeURI(Name);
for(var a = 1;a<stackFiles.length;a++){
open(File(stackFiles));
Name = decodeURI(app.activeDocument.name).slice(0,-4);
activeDocument.activeLayer.duplicate(thisDoc);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
thisDoc.layers[0].name = Name;
}
// Possible to check if Photoshop action file exist?
doAction('webCompPs','SCRIPT CALLS');
var psdOptions = new PhotoshopSaveOptions();
psdOptions.embedColorProfile = true;
psdOptions.alphaChannels = true;
psdOptions.layers = true;
psdOptions.spotColors = true;
var name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
var path = app.activeDocument.path;
var saveFile = File(path + "/" + name );
app.activeDocument.saveAs(saveFile, psdOptions, true);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
