literature

Ps script, save current file as jpg w/ version no.

Deviation Actions

Reflective-Sentinal's avatar
Published:
396 Views

Literature Text

#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 +"*.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");
SaveJPEG(saveFile, 8);
}
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;
};
Disclamer! I didn't write this, and I don't know how to code. I found it here [link] www.ps-scripts.com

What I did with it was make an action doing these two things.
1. save the file. 2. run script (script exports a jpg, and sticks a number at the end.)

This lets me bind a single key to saving the file, and at the end of the piece I can take a look back and see how it evolved.

*I know that I have this in the wrong category, but I couldn't put it in what I thought was the right one. let me know where it should go and I will happily move it.
Comments0
Join the community to add your comment. Already a deviant? Log In