This checks for eps only by using the name, so if other files mistakenly are named ».eps« it probably would cause problems, and I havent provided a provision for avoiding over-writting existing tiffs of the same names, but You could give this a try:
#target photoshop;
var dlg = new Window('dialog', "save flattened tiffs of eps-files", [500,300,880,525]);
//filter for checking if entry is numeric, thanks to xbytor;
numberKeystrokeFilter = function() {
this.text = this.text.replace(",", ".");
if (this.text.match(/[^\-\.\d]/)) {
this.text = this.text.replace(/[^\-\.\d]/g, '');
}
};
//create the entry for resolution;
dlg.msgPnl = dlg.add('panel', [25,100,355,170], 'resolution');
dlg.msgPnl.msgEt = dlg.msgPnl.add('edittext', [15,20,135,40], 150, {multiline:false});
dlg.msgPnl.msgEt.onChange = numberKeystrokeFilter;
//create a field for folder-selection;
dlg.folderPnl = dlg.add('panel', [25,25,355,90]);
dlg.folderPnl.btn = dlg.folderPnl.add('button', [12,7,313,17], 'select a folder to process', {name:'remove'});
dlg.folderPnl.folderName = dlg.folderPnl.add('statictext', [12,35,313,55], "none selected", {multiline:false});
// select a folder-function;
function folderSelection (theFolder) {
var theFolder = Folder.selectDialog ("select a folder");
dlg.folderPnl.folderName.text = String(theFolder);
};
dlg.folderPnl.btn.onClick = folderSelection;
//fields for ok and cancel;
dlg.buildBtn = dlg.add('button', [25,185,175,195], 'OK', {name:'ok'});
dlg.cancelBtn = dlg.add('button', [185,185,355,195], 'Cancel', {name:'cancel'});
// show dialog;
var myReturn = dlg.show ();
//////////// the operation //////////////////
if (myReturn == true && dlg.folderPnl.folderName.text != "none selected") {
// retrieve file-list and resolution;
var theFolder = dlg.folderPnl.folderName.text;
var theFileList = Folder(theFolder).getFiles();
var theResolution = dlg.msgPnl.msgEt .text;
// do the thing;
for (var m = 0; m < theFileList.length; m++) {
// getting the name and location;
var docName = theFileList .name;
var docPath = theFileList .path;
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
// open only files whose names end on ».eps«;
if (docName.slice(-4) == ".eps") {
// =======================================================
var idOpn = charIDToTypeID( "Opn " );
var desc1 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
desc1.putPath( idnull, new File( theFileList ) );
var idAs = charIDToTypeID( "As " );
var desc2 = new ActionDescriptor();
var idRslt = charIDToTypeID( "Rslt" );
var idRsl = charIDToTypeID( "#Rsl" );
desc2.putUnitDouble( idRslt, idRsl, theResolution );
var idAntA = charIDToTypeID( "AntA" );
desc2.putBoolean( idAntA, true );
var idEPSG = charIDToTypeID( "EPSG" );
desc1.putObject( idAs, idEPSG, desc2 );
executeAction( idOpn, desc1, DialogModes.NO );
// define the copy:
var theCopy = app.activeDocument;
// tiff options;
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrder.MACOS;
tifOpts.layers = false;
// make a copy, flatten it, delete paths, set it to 8bit;
theCopy.flatten();
theCopy.bitsPerChannel = BitsPerChannelType.EIGHT;
// save it;
theCopy.saveAs((new File(docPath+"/"+basename+".tif")),tifOpts,true);
theCopy.close(SaveOptions.DONOTSAVECHANGES);
}
else {}
}
};
// use it at your own risk;
If any of You spot unnecessary or stupid operations in the Script please let me know.
... View more