Help with bridge script that load files into layers, run some ps command and save as psd
Hi dear community, I need a bit of help from you.
I'm trying to develop a bridge script that from a root folder select images that shares some criteria (for now i'm doing this with names eg. aaa_base, jpeg, aaa_02.jpeg, aaa:03.jpeg) and then load the images in layers, run some commands in ps and saves to psd.
It's a while i'm tring to achieve this but i'm stucked...
At the present moment, i'm able to select the pictures that shares the neme criteria, and eventually stack them in bridge. problems comes when it's time to load them in ps. I tryed to achieve the result in different ways but no success at all...
The code is the result of different scripts i found on this and other communities, but i'm not a develepor at all, and in the end i feel i'm far away from the result... can someone help me out?
the file "Load.jsx" in the code is the "Load files into stack.jsx " of ps.
i was wondering if there's a way to call directly from bridge tools->photoshop->load files into layers but i'm not able to find that option...
I appreciate any help, thank you.
var fileList = Folder(app.document.presentationPath).getFiles("*base*");
for(var a in fileList) {
var firstFile = decodeURI(fileList[a].name.match(/[^_]*/));
var filesToStack = Folder(app.document.presentationPath).getFiles("*"+firstFile+"*");
if (filesToStack.length > 1 ) {
app.document.deselectAll();
for(var s in filesToStack) {
app.document.select(new Thumbnail(filesToStack[s]));
}
var bt = new BridgeTalk;
bt.target = "photoshop";
app.bringToFront();
var loadLayersFromScript = true;
//var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets");
//var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts");
var strFile2Stack = "Load.jsx";
var ipFilePath ="C:/"+ strFile2Stack;
$.writeln(ipFilePath);
var ipFile = new File (ipFilePath);
$.evalFile( ipFile );
loadLayers.intoStack(app.document.selections);
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
var outputFolder = new Folder("/stack");
if(!outputFolder.exists) outputFolder.create();
var saveFile = new File(outputFolder + '/'+ Name +'.psd');
var Count = activeDocument.layers.length;
for(var d = 0 ;d < Count; d++) {
activeDocument.activeLayer = activeDocument.layers;
/* amend to use your action N.B. it is case sensitive */
doAction("Action Name","Action Set");
}
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
