Here are some of the scripts from those "broken" links:
/*
automate save as or export with sequential file names
https://community.adobe.com/t5/photoshop/automate-save-as-or-export-with-sequential-file-names/td-p/9003836
2020 - Original script modified to remove the original filename from the sequential output file
https://forums.adobe.com/message/4453915#4453915
*/
#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;
}
#target photoshop
main();
function main() {
if (!documents.length) return;
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
Name = Name.replace(/\d+$/, '');
layerName = app.activeDocument.activeLayer.name.replace(/\.[^\.]+$/, '');
combinedName = Name + "_" + layerName;
try {
var savePath = activeDocument.path;
} catch (e) {
alert("You must save this document first!");
}
var fileList = savePath.getFiles(combinedName + "*.psd").sort().reverse();
var Suffix = 0;
if (fileList.length) {
Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
}
Suffix = zeroPad(Suffix + 1, 4);
var saveFile = File(savePath + "/" + combinedName + "_" + Suffix + ".psd");
SavePSD(saveFile);
}
function SavePSD(saveFile) {
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
psdSaveOptions.layers = true;
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
}
function zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;
}
#target photoshop
main();
function main() {
if (!documents.length) return;
var Name = app.activeDocument.activeLayer.name.replace(/\.[^\.]+$/, '');
try {
var savePath = activeDocument.path;
} catch (e) {
alert("You must save this document first!");
}
var fileList = savePath.getFiles(Name + "*.psd").sort().reverse();
var Suffix = 0;
if (fileList.length) {
Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
}
Suffix = zeroPad(Suffix + 1, 4);
var saveFile = File(savePath + "/" + Name + "_" + Suffix + ".psd");
SavePSD(saveFile);
}
function SavePSD(saveFile) {
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
psdSaveOptions.layers = true;
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
}
function zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;
}
#target photoshop
main();
function main(){
if(!documents.length) return;
var Name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
Name = Name.replace(/\d+$/,'');
try{
var savePath = activeDocument.path;
}catch(e){
alert("You must save this document first!");
}
var fileList= savePath.getFiles(Name +"*.psd").sort().reverse();
var Suffix = 0;
if(fileList.length){
Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
}
Suffix= zeroPad(Suffix + 1, 4);
var saveFile = File(savePath + "/" + Name + "_" + Suffix + ".psd");
SavePSD(saveFile);
}
function SavePSD(saveFile){
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
psdSaveOptions.layers = true;
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
};
function zeroPad(n, s) {
n = n.toString();
while (n.length < s) n = '0' + n;
return n;
};
if (app.documents.length) {
try { var f = app.activeDocument.fullName } catch (e) {
var p = new Folder; f = p.selectDlg(); if (f) f = File(f + '/' + app.activeDocument.name)
}
if (f) {
activeDocument.saveAs(createUniqueFileName(f))
activeDocument.close()
}
}
function createUniqueFileName(f) {
var inPath = decodeURI(f.parent),
inFile = decodeURI(f.name).replace(/\.[^\.]+$/, '').replace(/_\d+$/,''),
inExt = '.psd',
uniqueFileName = File(inPath + '/' + inFile + inExt),
fileNumber = 1
while (uniqueFileName.exists) {
uniqueFileName = File(inPath + '/' + inFile + "_" + ('000' + fileNumber).slice(-3) + inExt)
fileNumber++;
}
return uniqueFileName
}
if (app.documents.length) {
try { var f = app.activeDocument.fullName } catch (e) {
var p = new Folder; f = p.selectDlg(); if (f) f = File(f + '/' + app.activeDocument.name)
}
if (f) {
(o = new JPEGSaveOptions ()).quality = 12
activeDocument.saveAs(createUniqueFileName(f), o)
activeDocument.close()
}
}
function createUniqueFileName(f) {
var inPath = decodeURI(f.parent),
inFile = decodeURI(f.name).replace(/\.[^\.]+$/, '').replace(/_\d+$/,''),
inExt = '.jpg',
uniqueFileName = File(inPath + '/' + inFile + inExt),
fileNumber = 1
while (uniqueFileName.exists) {
uniqueFileName = File(inPath + '/' + inFile + "_" + ('000' + fileNumber).slice(-3) + inExt)
fileNumber++;
}
return uniqueFileName
}
try {
while (1)
{
var _file = new File("C:\\Users\\KoolKATZDesigns\\Desktop\\Script Tests\\Names.txt");
var number = 0;
if (_file.exists)
{
_file.open("r");
number = Number(_file.read());
if (_file.error) { alert("Params read error!", "Error", true); _file.close(); break; }
_file.close();
}
++number;
_file.open("w");
_file.write(number);
if (_file.error) { alert("Params save error!", "Error", true); _file.close(); break; }
_file.close();
var _name = "DOC_" + number;
app.documents.add(UnitValue(1920, "px"), UnitValue(1080, "px"), 72, _name, NewDocumentMode.RGB, DocumentFill.WHITE, 1, BitsPerChannelType.EIGHT, "sRGB IEC61966-2.1");
break;
}
}
catch (e) { alert(e); }