This script will save a previously saved document as a new PSB file (offering to overwrite an existing file if found). The new PSB file will use the same name and location as the original file.
If the document is unsaved, the save will default to PSB, using a standard dialog to select the save location and filename.
There is an optional code block that you can uncomment to prompt to permanently delete the original file if the original file was a PSD (no trash/bin/recycle bin).
/*
Default Save As to PSB.jsx
v1.0 - 13th August 2024, Stephen Marsh
https://community.adobe.com/t5/photoshop-ecosystem-ideas/photoshop-ability-to-set-default-quot-save-save-as-quot-file-type-to-psb/idc-p/14795865
Info:
- Previously saved files will save as to PSB to the same location with the same name
- Unsaved files will offer a dialog to save as to PSB, allowing the choice of name and location
- Optional: Uncomment the code block to permanently delete the original PSD
*/
#target photoshop
(function () {
if (app.documents.length) {
var theName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
try {
app.activeDocument.path;
var thePath = app.activeDocument.path;
var theFile = new File(thePath + "/" + theName + ".psb");
if (theFile.exists) {
if (!confirm("The PSB file exists, overwrite?", true))
return;
}
saveAsPSB(new File(thePath + "/" + theName + ".psb"), false, DialogModes.NO);
} catch (e) {
var thePath = new Folder("~/Desktop");
saveAsPSB(new File(thePath + "/" + theName + ".psb"), false, DialogModes.ALL);
}
/*
//////////
var thePSD = new File(thePath + "/" + theName + ".psd");
if (thePSD.exists) {
if (!confirm("Permanently delete the original PSD?", true))
return;
}
thePSD.remove();
//////////
*/
} else {
alert("You must have a document open to use this script!");
}
function saveAsPSB(thePath, asCopy, theDialog) {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var descriptor2 = new ActionDescriptor();
descriptor.putObject(s2t("as"), s2t("largeDocumentFormat"), descriptor2);
descriptor.putPath(s2t("in"), thePath);
descriptor.putBoolean(s2t("copy"), asCopy);
descriptor.putBoolean(s2t("lowerCase"), true);
executeAction(s2t("save"), descriptor, theDialog);
}
}());
... View more