Quick Save as Versions with Script?
I'm looking to modify a script I found online but unfortunately I don't know enough Javascript to figure it out.
Here's the original code from this blog post:
#target photoshop;
if (app.documents.length > 0) {
var thedoc = app.activeDocument;
var docName = thedoc.name;
if (docName.indexOf(".") != -1) {
var basename = docName.match(/(.*)\.[^\.]+$/)[1]
} else {
var basename = docName
}
//getting the location, if unsaved save to desktop;
try {
var docPath = thedoc.path
} catch (e) {
var docPath = "~/Desktop"
}
var jpegOptions = new JPEGSaveOptions();
jpegOptions.quality = 9;
jpegOptions.embedColorProfile = true;
jpegOptions.matte = MatteType.NONE;
var filename = docPath + '/' + basename + "-" + getTime() + '.jpg';
thedoc.saveAs((new File(filename)), jpegOptions, true);
};
function getTime(){
var currentTime = new Date();
//Make single-digit mins show up as 6:01 and not 6:1
var minutes = currentTime.getMinutes();
if (minutes < 10) {
minutes = "0" + minutes;
}
var timeStamp = currentTime.getFullYear() + "-"
+ (currentTime.getMonth() + 1) + "-"
+ currentTime.getDate() + "-"
+ currentTime.getHours() + "."
+ minutes + "."
+ currentTime.getSeconds() + "."
+ currentTime.getMilliseconds();
return timeStamp;
}
What I'm trying to do is instead of saving with a timestamp, I'd rather have the script automatically detect the most recent version (eg: MyPicture_04.jpg) and save as the next logical increment (eg: MyPicture_05.jpg)
Anyone know how I'd be able to go about scripting that?
Thanks!
