Links to some of the alternative incremental scripts:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-increments-and-save-embedded-colour-profile-jpg-and-png/td-p/14775268
https://community.adobe.com/t5/photoshop-ecosystem-discussions/can-anyone-write-me-a-photoshop-script-to-incremental-save-a-pdf/td-p/13303085
https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-for-incremental-saving/td-p/13235725
https://community.adobe.com/t5/photoshop-ecosystem-discussions/repeat-action-and-save-file/td-p/8532556
https://community.adobe.com/t5/photoshop/saving-sequential-file-names-of-the-same-file-to-multiple-files/td-p/12023959
https://community.adobe.com/t5/photoshop/automate-save-as-or-export-with-sequential-file-names/m-p/9003836
https://community.adobe.com/t5/photoshop/saving-sequential-file-names-of-the-same-file-to-multiple-files/td-p/12023959
https://community.adobe.com/t5/photoshop/looking-for-photoshop-script-that-gives-a-file-a-unique-name-saves-and-close/td-p/10998808
https://community.adobe.com/t5/photoshop-ecosystem-discussions/saving-sequential-file-names-of-the-same-file-to-multiple-files/m-p/12025355
https://community.adobe.com/t5/photoshop-ecosystem-discussions/action-overwrites-jpeg-file-after-the-first-copy/td-p/11723178
#target photoshop
main();
function main() {
if (!documents.length) return;
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
try {
var savePath = activeDocument.path;
} catch (e) {
alert("You must save this document first!");
}
var fileList = savePath.getFiles("*.jpg").sort().reverse();
var Suffix = 0;
if (fileList.length) {
Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
}
Suffix = zeroPad(Suffix + 1, 3);
//var saveFile = File(savePath + "/" + Name + "_" + Suffix + ".jpg");
var saveFile = File(savePath + "/" + Suffix + ".jpg");
SaveJPEG(saveFile, 8); // JPEG compression level
}
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);
}
function zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;
}
// Save PNG next to PSD (Incremental numbers).jsx
#target photoshop
var savePSD = false; // If set true the psd document is saved every time the script runs...
var folderName = ' (Frames)';
try {
var doc = app.activeDocument;
var fileExists = false;
try { if ( savePSD ) doc.save(); } catch(e){}
try {
fileExists = doc.path;
}
catch(e){
var idsave = charIDToTypeID( "save" );
var desc50 = new ActionDescriptor();
var idIn = charIDToTypeID( "In " );
desc50.putPath( idIn, new File( Folder.desktop.fullName ) );
var idDocI = charIDToTypeID( "DocI" );
desc50.putInteger( idDocI, 196 );
var idsaveStage = stringIDToTypeID( "saveStage" );
var idsaveStageType = stringIDToTypeID( "saveStageType" );
var idsaveSucceeded = stringIDToTypeID( "saveSucceeded" );
desc50.putEnumerated( idsaveStage, idsaveStageType, idsaveSucceeded );
executeAction( idsave, desc50, DialogModes.ALL );
fileExists = doc.path;
}
if ( fileExists ) {
saveNewVersion( doc );
}
}
catch( e ) {
// remove comments below to see error for debugging
// alert( e );
}
function saveNewVersion( doc, docName ) {
var extension = '.png';
var docName = doc.name.substring(0, doc.name.lastIndexOf('.'));
var docPath = doc.path;
var outputPath = docPath + '/' + doc.name + folderName;
var outputFolder = new Folder( outputPath );
if( !outputFolder.exists ) { outputFolder.create(); }
var verisonsList = outputFolder.getFiles( '*' + extension );
var versionsLength1 = verisonsList.length;
var number = getVersionNumber( docName, verisonsList );
var filename = number + extension;
doc.exportDocument( File( outputPath + '/' + filename ), ExportType.SAVEFORWEB, exportOptions() );
app.beep();
}
function getVersionNumber( docName, verisonsList ) {
var number = 0;
for ( var i = 0; i < verisonsList.length; i++ ) {
var file = verisonsList[i];
var fileName = File(file).displayName;
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
// Start looking for the version number if PSD filename contains doc name...
var versionNumber = fileName.match(/^[0-9]*/);
if ( versionNumber ) {
versionNumber = parseInt( versionNumber ,10);
if ( number < versionNumber ) {
number = versionNumber;
}
}
}
return number + 1;
}
function exportOptions() {
var options = new ExportOptionsSaveForWeb();
options.format = SaveDocumentType.PNG;
options.quality = 100;
return options;
}
... View more