Ok, here is another script that you will need to modify before use! To run an action in javaScript it needs the Action Name and ActionSet Name and these are case sensitive! I.E. doAction("Align","MyStackActions"); Lets hope this works. #target bridge if( BridgeTalk.appName == "bridge" ) { stacksToLayersII = new MenuElement("command", "Stacks To LayersII", "at the end of submenu/Stack"); } stacksToLayersII.onSelect = function () { var stacks = app.document.stacks; var stackCount = stacks.length; for(var s = 0;s<stackCount;s++){ var stackFiles = getStackFiles( stacks ); var Name = decodeURI(stackFiles[0].name).replace(/\.[^\.]+$/, ''); if(stackFiles.length> 1){ var bt = new BridgeTalk; bt.target = "photoshop"; var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+stackFiles.toSource() + "," + Name.toSource() +");"); bt.body = myScript; bt.onResult = function( inBT ) {myReturnValue(inBT.body); } bt.send(500); } } function getStackFiles( stack ){ var files = new Array(); for( var f = 0; f<stack.thumbnails.length;f++){ files.push(stack.thumbnails .spec); } return files; }; function myReturnValue(str){ res = str; } function psRemote(stackFiles,Name){ app.bringToFront(); var loadLayersFromScript = true; var strPresets = localize ("$$$/ApplicationPresetsFolder/Presets=Presets"); var strScripts = localize ("$$$/PSBI/Automate/ImageProcessor/Photoshop/Scripts=Scripts"); var strFile2Stack = "Load Files into Stack.jsx"; var ipFilePath = app.path + "/" + strPresets + "/" + strScripts + "/" + strFile2Stack; var ipFile = new File (ipFilePath); $.evalFile( ipFile ); loadLayers.intoStack(stackFiles); psdSaveOptions = new PhotoshopSaveOptions(); psdSaveOptions.embedColorProfile = true; psdSaveOptions.alphaChannels = true; var BT = new BridgeTalk(); BT.target='bridge'; BT.body ="var ftn = " + script.toSource() + "; ftn();"; BT.onResult = function( inBT ) { inFolder = inBT.body; } BT.onError = function( ohShi ) { alert(ohShi.body)} BT.send(10); var outputFolder = new Folder(inFolder + "/Combined"); if(!outputFolder.exists) outputFolder.create(); var saveFile = new File(outputFolder + '/'+ Name +'.tif'); try{ /******Remove these lines if you want your action to do all the work ***/ app.runMenuItem(stringIDToTypeID('selectAllLayers')); var desc1 = new ActionDescriptor(); var ref1 = new ActionReference(); ref1.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') ); desc1.putReference( charIDToTypeID('null'), ref1 ); desc1.putEnumerated( charIDToTypeID('Usng'), charIDToTypeID('ADSt'), stringIDToTypeID('ADSContent') ); executeAction( charIDToTypeID('Algn'), desc1, DialogModes.NO ); /****************************************************************************/ /**This actionset name needs to be amended to suit N.B. IT IS CASE SENSITIVE**/ /**** This section runs an action on each layer in turn ****/ app.runMenuItem(stringIDToTypeID('selectNoLayers')); activeDocument.activeLayer = activeDocument.layers[1]; 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("Align","Action Set Name"); } /*************************************************************************/ tiffSaveOptions = new TiffSaveOptions(); tiffSaveOptions.embedColorProfile = true; tiffSaveOptions.alphaChannels = true; tiffSaveOptions.layers = true; tiffSaveOptions.imageCompression = TIFFEncoding.NONE; activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE); app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); }catch(e){alert(e + "\n" + e.line);}; function script(){ return decodeURI(Folder(app.document.presentationPath).fullName).toString(); } } };
... View more