I'm trying to make an incremental save script like the one in autodesk maya.
I've got it working exept there is one thing that annoys me. Saving larges files can take a while and during the save action photoshop freezes.
I would like to include a progressbar or something of the like that shows it's busy. Is there a way to do this? All the progressbar scripts that i've seen appear to have a lot of little actions which makes updating the progressbar easy.
this is the script i've got:
Code: Select all//Use on your own risk!!!
//This script make a copy of your original file with an added datestamp to a "version" folder.
//If the "version" folder doesn't exist one will be created.
//It then overwrites the original file with the current version.
save();
function getName( myDocName){
//Create new dateObject
var d = new Date();
//dstring contains something like: "V130416_1143"
var dstring = "_V"+("" + d.getFullYear()).slice(-2)+"" +("0" + (d.getMonth() + 1)).slice(-2)+""+d.getDate()+"_"+d.getHours()+""+d.getMinutes();
var myTargetDocName= myDocName.substring(0, myDocName.lastIndexOf("."));
// if it has already a save timeprint -> remove the timeprint
if(myTargetDocName.lastIndexOf("_V"+("" + d.getFullYear()).slice(-2))>0){
myTargetDocName = myTargetDocName.substring(0,myTargetDocName.lastIndexOf("_V"+("" + d.getFullYear()).slice(-2) ));
}
myTargetDocName += dstring ;
return myTargetDocName;
}
function save() {
//store the dialog preferences
var startDisplayDialogs = app.displayDialogs;
//stop dialogs from showing
//app.displayDialogs = DialogModes.NO;
//check if there is an open document
if (app.documents.length > 0) {
var myDoc = app.activeDocument;
var myDocName = myDoc.name;
//check if the file has been saved as a psd before
if ((myDocName.slice(-3)).toLowerCase()=="psd"){
var myFolder = myDoc.path;
var myNewName = getName(myDocName);
//if there is no version folder create one
var versionFolder = new Folder(myFolder.fsName + "/version");
if (!versionFolder.exists){
versionFolder.create();
}
if (myNewName != "") {
myNewName += '.psd';
var myNewFile = new File(myFolder.fsName + '/' + myNewName);
File(myFolder.fsName + '/' + myDocName).copy(versionFolder + '/' + myNewName);
myDoc.save();
//alert("file saved in: " + myFolder.fsName);
}
}else{
//Dialog asking for the filename and location
var myNewName = File.saveDialog("Save as master file","Photoshop:*.psd");
//Set the file Options
var psdOpts = new PhotoshopSaveOptions();
psdOpts.alphaChannels = true;
psdOpts.annotation = true;
embedColorProfile = true;
psdOpts.layers = true;
psdOpts.spotColors = true;
//Check if a filename is entered
if (myNewName != null) {
//check if the filename already exists
if (myNewName.exists){
//ask for confirmation before overwriting the file
if(confirm("Overwrite the existing file?",true,"Overwrite?")){
myDoc.saveAs(myNewName, psdOpts,false);
}
}else{
myDoc.saveAs(myNewName,psdOpts,false,Extension.LOWERCASE);
}
}
}
//if the file wasn't saved give a warning
if (!myDoc.saved){
alert("Save Failed!");
}
}
//Reset the dialog settings to the previous state
app.displayDialogs = startDisplayDialogs
}
Save progress indicator
-
Mike Hale
Save progress indicator
I think your main problem will be that when Photoshop is busy saving the script will not run and can't update the progressbar. The other problem will be that Photoshop doesn't give any feedback on the save process so you would not be able to know what the current value of the progressbar should be.
Of course CS6 does background saves and the percent saved in already shown during the save.
Of course CS6 does background saves and the percent saved in already shown during the save.
-
bart_janssen
Save progress indicator
Thanks Mike.
Don't suppose the background save is accesable with script is it? That way I would be able to call it instead of the normal save function.
Don't suppose the background save is accesable with script is it? That way I would be able to call it instead of the normal save function.