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

Help! Fix my javascript to save a bmp with suffix in the same folder as the previous save.

$
0
0

Here's my current javascript:

 

 

#target photoshop

 

 

// sets document preferences to inches

app.preferences.rulerUnits = Units.INCHES

 

 

// these are our values for the END RESULT width and height (in inches) of our image

var fWidth = 11.73;

var fHeight = 5.97;

 

 

var CurrentDLPFile=app.activeDocument

var CurrentDLPFileName= CurrentDLPFile.name

var CurrentDLPFilePath="~/Desktop/fetch"

var f = File.saveDialog('Save Where?',''); 

 

 

// in case we double clicked the file

app.bringToFront();

 

 

// resizes the canvas to 11.73 x 5.97 inches

CurrentDLPFile.resizeCanvas(UnitValue(fWidth,"in"),UnitValue(fHeight,"in"));

 

 

// flattens all layers

CurrentDLPFile.flatten();

 

 

// saves as photoshop file

if (f!=null) CurrentDLPFile.saveAs(f,undefined);

 

 

// splits channels

CurrentDLPFile.splitChannels();

 

 

// converts active K seperation to bitmap form

var bitsaveoptions = new BitmapConversionOptions()

 

 

bitsaveoptions.method = BitmapConversionType.HALFTONESCREEN

bitsaveoptions.angle = 45

bitsaveoptions.frequency = 55

bitsaveoptions.resolution = 300

bitsaveoptions.shape = BitmapHalfToneType.ROUND

 

 

app.activeDocument.changeMode(ChangeMode.BITMAP,bitsaveoptions);

 

// THIS IS WHERE I'M HAVING ISSUES- I want to save the file (which at this point is a bmp), with a suffix of 1 in the same folder; and then close the file.

var doc = app.activeDocument;

var docName = doc.name;

docName = docName.match(/(.*)(\.[^\.]+)/) ? docName = docName.match(/(.*)(\.[^\.]+)/):docName = [docName, docName];

var suffix = '_1';

var saveName = new File(decodeURI(doc.path)+'/'+docName[1]+suffix+'.bmp');

 

function saveFile(app.activeDocument, saveName);


Viewing all articles
Browse latest Browse all 12244

Trending Articles



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