Please help - Rewriting script to affect all files in folder, not just one (Photoshop, JavaScript)
Hey guys
,
I dont know much about scripting, but i somehow managed to put together a script, that takes *.ps (postscript) file, open it in photoshop with some settings, and then save it in two different sizes to two different folders as jpeg. But unfortunately, it only affects one *.ps file (in a specified path). I have hundreds of those *.ps files and just thinking about opening it one by one makes me feel dizzy
Is there any way i could select folder with all those *.ps files and script would make those changes to all of them?
I would really appreciate any help
.
Here's my script:
//open eps with settings 1050x750px+rgb
var epsOpts = new EPSOpenOptions();
epsOpts.antiAlias = true;
epsOpts.mode = OpenDocumentMode.RGB;
epsOpts.resolution = 72;
epsOpts.constrainProportions = true;
epsOpts.width = new UnitValue( 1050, 'px' )
var f = new File('C:/mypath/myfile.ps' );
app.open( f, epsOpts );
//save 1050px
var doc = app.activeDocument;
var Path = 'C:/mypath/resize/1050/';
var Name = doc.name.replace(/\.[^\.]+$/, '');
var saveFile = File(Path + "/" + Name + ".jpg");
SaveJPEG(saveFile, 12);
function SaveJPEG(saveFile, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}
//resize to 360px
app.activeDocument.resizeImage('360 pixels', '257 pixels', 72, ResampleMethod.BICUBIC);
//save 360px
var doc360 = app.activeDocument;
var Path360 = 'C:/mypath/resize/360/';
var Name360 = doc.name.replace(/\.[^\.]+$/, '');
var saveFile360 = File(Path360 + "/" + Name360 + ".jpg");
SaveJPEG360(saveFile360, 12);
function SaveJPEG360(saveFile360, jpegQuality){
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality;
activeDocument.saveAs(saveFile360, jpgSaveOptions, true,Extension.LOWERCASE);
}
//close file
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
Thank you in advance
!
