Quantcast
Channel: Adobe Community : Popular Discussions - Photoshop Scripting
Viewing all articles
Browse latest Browse all 12244

script flow control

$
0
0

I am trying to figure out the logic to implement a save folder dialog into a Bridge batch processing script.

I posted a similar question in the bridge forum complicated question: dialog box-batch processing script

Script: Open files as Layers in Photoshop

 

The  main concept is to display a save dialog when the script executes to set save folder destination.

Once the user enters the data the script executes batch processing image stacks from Bridge.

The folder dialog would only display once every time the script is launched.

 

Which javascript flow control will allow this behavior?

 

I have added the folder dialog to the script. Every time the script encounters a Bridge image stack it calls the save folder dialog.

 

#target bridge 

 

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

 

}


Viewing all articles
Browse latest Browse all 12244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>