Skip to main content
arwen morgenstern
Known Participant
October 11, 2013
Answered

Bridge script to automate "open files as layers in photoshop"?

  • October 11, 2013
  • 1 reply
  • 5345 views

Hello, i badly need a solution for this problem:

Working with HDR Photography I usually end up with many exposure brackets of 7 raw-shots. After adjusting them in Lightroom 5.2, i want to open each exposure bracket as layers in Photoshop CS6 and save it as PSD.

In Lightroom (or Bridge) there is the command "open as layers in photoshop." The big Problem is: Doing this bracket for bracket it takes years to process. And then i have to save every single File within photoshop, wich takes another eternity.

Is there a script or plugin to automate this task? Something that processes Image stacks perhaps? Or something similar from Bridge?

I ́ve found a bridge Script here:

http://forums.adobe.com/message/42463...

It supposed to do exactly what im looking for... But it don ́t work in Bridge CS6 😞

-kai

This topic has been closed for replies.
Correct answer I have gone

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 );

      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.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));

    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);

}

};

Inspiring
October 11, 2013

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.

arwen morgenstern
Known Participant
October 13, 2013

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 );
      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.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));
    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

I have goneCorrect answer
Inspiring
October 13, 2013

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 );

      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.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));

    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);

}

};