Skip to main content
Inspiring
November 8, 2014
Question

complicated question: dialog box-batch processing script

  • November 8, 2014
  • 1 reply
  • 560 views

I am adapting the working script I found on this forum.

Script: Open files as layers in Photoshop

https://forums.adobe.com/thread/1313579

The goal of the adaptation is to include a javascript Folder dialog to set the save folder destination at run time and

use this folder destination for the remaining script batch processing functions.

Presently, the script loads a Bridge stack as Photoshop layers and saves the layered tiff using the Folder dialog.

The folder dialog is manifesting every time the script encounters a Bridge stack.

The question is what is the correct script logic to set the destination folder once at run time and keep this destination

folder for the stack batch processing.

#target bridge

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 tifOptions = new TiffSaveOptions();

tifOptions = new TiffSaveOptions();

tifOptions.embedColorProfile = true;

tifOptions.imageCompression = TIFFEncoding.TIFFLZW;

tifOptions.alphaChannels = false;

tifOptions.byteOrder = ByteOrder.MACOS;

tifOptions.layers = true;

var theFolder = Folder.selectDialog ("Select Folder");

if (theFolder) {

        var myFile = new File( theFolder + "/" + app.activeDocument.name);

        app.activeDocument.saveAs(myFile, tifOptions, true);  

    }

app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);

}

This topic has been closed for replies.

1 reply

ojodegatoAuthor
Inspiring
November 8, 2014

I am thinking the Folder dialog is not correct for this application.

On a second thought a persistent dialog to set the save folder path and run the script from the persistent dialog can make sense.

Any ideas?