-
1. Re: Bridge script to automate "open files as layers in photoshop"?
Philip Cord Oct 11, 2013 12:09 PM (in response to arwen morgenstern)It looks as if you didn't use a plain text editor to copy the script, as the error message does not reflect what the first line of the code is.
Try doing it again this time using ExtendScript Toolkit that is installed with Photoshop.
-
2. Re: Bridge script to automate "open files as layers in photoshop"?
arwen morgenstern Oct 13, 2013 6:16 AM (in response to Philip Cord)Philip, thanks for your answer. I am a complete newbie, so I write exactly what I did:
1.) I´m on windows 7 64-bit with adobe Master Collection CS6.
2.) I have loaded the following script using copy + past into the ExtendScript Toolkit (CS6):
var stacks = app.document.stacks;
var stackCount = stacks.length;
for(var s = 0;s<stackCount;s++){
var stackFiles = getStackFiles( stacks[s] );
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[f].spec);
}
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[a]));
Name = decodeURI(app.activeDocument.name).slice(0,-4);
activeDocument.activeLayer.duplicate(thisDoc);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
thisDoc.layers[0].name = Name;
}
var saveFile = new File('~/desktop/'+(new Date().getTime().toString())+'.psd');
app.activeDocument.saveAs(saveFile);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}3.) In the toolkit I start the script (with target application Bridge CS6-64 bit): Everything works as expected.
4.) Then I save the script as a "stack-batch.jsx" in the folder "C: \ Users \ kai \ AppData \ Roaming \ Adobe \ Bridge CS6 \ Startup Scripts \ Stack Batch.jsx"
5.) At the start of Bridge I get the Following Following error message:"Error in C: \ Users \ ... \ AppData \ Roaming \ Adobe \ Bridge CS6 \ Startup
Scripts \ stack Batch.jsx
Line 1: var = app.document.stacks stacks;
undefined is not an object "
6.) Bridge and then starts the script is not enabled.Thanks for a hint what I'm doing wrong ... Or what might not be right in the script!
-kai
-
3. Re: Bridge script to automate "open files as layers in photoshop"?
Philip Cord Oct 13, 2013 11:43 AM (in response to arwen morgenstern)Ah I see what the problem is, it is only written for use from ExtendScript Toolkit, the follow code should work, and you should then be able to run the script from the Tools menu.
#target bridge if( BridgeTalk.appName == "bridge" ) { var batchStack = new MenuElement( "command","Batch Stack", "at the end of Tools" , "batchStack" ); } batchStack .onSelect = function () { var stacks = app.document.stacks; var stackCount = stacks.length; for(var s = 0;s<stackCount;s++){ var stackFiles = getStackFiles( stacks[s] ); 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[f].spec); } 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[a])); Name = decodeURI(app.activeDocument.name).slice(0,-4); activeDocument.activeLayer.duplicate(thisDoc); app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); thisDoc.layers[0].name = Name; } var saveFile = new File('~/desktop/'+(new Date().getTime().toString())+'.psd'); app.activeDocument.saveAs(saveFile); app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); } }; -
4. Re: Bridge script to automate "open files as layers in photoshop"?
arwen morgenstern Oct 13, 2013 4:21 PM (in response to Philip Cord)Ahh .. this looks great! Huge thank you!
I must admit that I am not a web developer but a photographer (who likes to fiddle). So sorry for my ignorance :-)
Philip, unfortunately, I still see an error in the script:
I run the script within Bridge on a folder with 10 image stacks (4 stacks consist of 5 shots, 6 stacks of 7 shots). But unfortunately, the script sometimes processed 6 stacks, other times 7 stacks (as saved psd files) ... And ends without any further error message. So i end up with just a part of the existing Stacks :-(
Do you have any idea what could be the reason? -
5. Re: Bridge script to automate "open files as layers in photoshop"?
Philip Cord Oct 15, 2013 4:10 AM (in response to arwen morgenstern)Sorry this is beyond me, looks like you would need the help of the original poster.
You should be able to contact him @ http://www.ps-bridge-scripts.talktalk.net/
Best of luck.

