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

Save All Open Files

$
0
0

Using CS3. I've created an action to Crop and straighten, and I'm using it on Batch options to split hundereds of scanned images.

 

I managed to find two old scripts from c.pfaffenbichler (much appreciated, thanks) which I've managed to adapt a little into a single one, which save the open files. In essence it works perfectly, although it always saves it to the default location (in the original it was the desktop, I've amended it to a Folder on my images disk called Split).

 

I'd be grateful if someone could help by explaining why the initial save to the source directory does not work.

 

many thanks

 

Colin

 

 

// save all open documents;

// 2011, use it at your own risk;

#target photoshop;

if (app.documents.length > 0) {

var theFirst = app.activeDocument;

var theDocs = app.documents;

// psd options for unsaved files;

psdOpts = new PhotoshopSaveOptions();

psdOpts.embedColorProfile = true;

psdOpts.alphaChannels = false;

psdOpts.layers = true;

psdOpts.spotColors = true;

// go through all files;

for (var m = 0; m < theDocs.length; m++) {

     var theDoc = theDocs[m];

     app.activeDocument = theDoc;

// getting the name and location;

     var docName = theDoc.name;

// thanks to xbytor for the regexp;

     if (docName.indexOf(&quot;.&quot;) != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]}

     else {var basename = docName};

// getting the location, if unsaved save to desktop;

          try {

          var docPath = theDoc.path;

// jpg options;

var jpegOptions = new JPEGSaveOptions();

jpegOptions.quality = 10;

jpegOptions.embedColorProfile = false;

jpegOptions.matte = MatteType.NONE;

// save the file if unsaved;

          if (theDoc.saved == false) {theDoc.save()}

          }

// if file has not been saved yet save to E:\Split;

     catch (e) {

          var docPath = &quot;E:\Split&quot;;

          theDoc.saveAs((new File(docPath+'/'+basename+&quot;.jpg&quot;)), jpegOptions, false, Extension.LOWERCASE);

          };

     };

app.activeDocument = theFirst;

};


Viewing all articles
Browse latest Browse all 12244

Trending Articles



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