Hi there!
I am creating an action that has 3 basic functions;
- Save file with incremental number (ex: figuredrawing001.png)
- Close the file (without "are you sure" warning)
- Create new document figuredrawing
This is what I have so far
I am creating this to quickly save 30 second figure drawings and refresh my canvas.
I found an ancient script online that did roughly this but for some reason it would stop without error (or notifying me) at 008 for no apparent reason and came with a whole host of other issues. (Like when I tried it after closing photoshop it started overwriting 001 again for instance)
Is there a way to set this up quickly under a hotkey? For reference this is the script that I was working with.
// This script will save the active document to a folder with an incremental sufix
// Change the options below to match your needs
var saveFolder = new Folder( 'E:/Specialization/30seconddrawing' ); //don't put the ending "/" this is for mac folders windows is /c/foldername
var saveSufixStart = '_';
var saveSufixLength = 3;
saveOptions = new PNGSaveOptions();
saveOptions.embedColorProfile = true;
saveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
saveOptions.matte = MatteType.NONE;
saveOptions.quality = 8;
// End of user options
//==========================================
var saveExt = 'png';
function zeroPad ( num, digit ){
var tmp = num.toString();
while (tmp.length < digit) { tmp = "0" + tmp;}
return tmp;
}
var docName = decodeURI ( activeDocument.name );
docName = docName.match( /(.*)(\.[^\.]+)/ ) ? docName = docName.match( /(.*)(\.[^\.]+)/ ) : docName = [ docName, docName, undefined ];
var saveName = docName[ 1 ]; // activeDocument name with out ext
var files = saveFolder.getFiles( saveName + '*.' + saveExt );// get an array of files matching doc name prefix
if( files.length == 0 ) { // no file with that name so start at one
var saveNumber = 1;
}
if( files.length == 1 ) { // one file found, see if it has a sufix
var fileName = decodeURI ( files[ 0 ].name );
fileName = fileName.match( /(.*)(\.[^\.]+)/ ) ? fileName = fileName.match( /(.*)(\.[^\.]+)/ ) : fileName = [ fileName, fileName, undefined ];
if( fileName[1].match( /_(\d{3})$/ ) == null ){
var saveNumber = 1;// does not have sufix so set to one
} else{// has sufix
var saveNumber = parseInt( fileName[ 1 ].match( /_(\d{3})$/ )[1] ) + 1; // strip the ext and get the sufix , convert to number and add 1
}
}
if( files.length > 1 ){
files.sort();
var fileName = decodeURI ( files[ files.length -1 ].name );
fileName = fileName.match( /(.*)(\.[^\.]+)/ ) ? fileName = fileName.match( /(.*)(\.[^\.]+)/ ) : fileName = [ fileName, fileName, undefined ];
var saveNumber = parseInt( fileName[ 1 ].match( /_(\d{3})$/ )[1] ) + 1; // strip the ext and get the sufix , convert to number and add 1
}
var saveFile = new File( saveFolder + '/' + saveName + '_' + zeroPad( saveNumber, saveSufixLength ) + '.' + saveExt );
activeDocument.saveAs( saveFile, saveOptions ,true ,Extension.LOWERCASE);