I have a great Java script that I’ve found online back in 2015. It works like a charm!
It saves the opened in Photoshop file with 1 click as high quality JPEG in the same folder as an original file:
#target photoshop
var saveFile = new File(activeDocument.path);
// =======================================================
var idsave = charIDToTypeID( "save" );
var desc8 = new ActionDescriptor();
var idAs = charIDToTypeID( "As " );
var desc9 = new ActionDescriptor();
var idEQlt = charIDToTypeID( "EQlt" );
desc9.putInteger( idEQlt, 12 );
var idMttC = charIDToTypeID( "MttC" );
var idMttC = charIDToTypeID( "MttC" );
var idNone = charIDToTypeID( "None" );
desc9.putEnumerated( idMttC, idMttC, idNone );
var idJPEG = charIDToTypeID( "JPEG" );
desc8.putObject( idAs, idJPEG, desc9 );
var idIn = charIDToTypeID( "In " );
desc8.putPath( idIn, new File( saveFile ) );
var idDocI = charIDToTypeID( "DocI" );
desc8.putInteger( idDocI, 35 );
var idCpy = charIDToTypeID( "Cpy " );
desc8.putBoolean( idCpy, false );
var idLwCs = charIDToTypeID( "LwCs" );
desc8.putBoolean( idLwCs, true );
var idsaveStage = stringIDToTypeID( "saveStage" );
var idsaveStageType = stringIDToTypeID( "saveStageType" );
var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );
desc8.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );
executeAction( idsave, desc8, DialogModes.NO );
But!
Is there a way to modify that script so it can:
-
Add the prefix, something like "_" at the beginning of the file (i.e. "_Image.jpg")
-
Close the original opened file in Photoshop without saving or asking to save it. I’ve found this line, but I’m unsure where to add it to the existing script:
app.activeDocument.close(SaveOptions.no);
It would make this amazing script even more useful and help me save so much time automating the process of saving over 7500 images I’m editing at the moment.
Thanks!
2
Answers
Stephen_A_Marsh from Adobe Support forums helped me with this code. Might as well share it here:
You’ve answered your own question! However here’s the code for saving a jpeg which isn’t Action Manager code, and is easier to read: