Copy link to clipboard
Copied
Is there any script to save time by exporting all saved snapshots as separate files using snapshot names?
Ah, yeah, it's that old problem with the forum software changeover where variables in square brackets were lost.
Try this, full credit to @SuperMerlin:
/* https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-all-history-snapshots-as-files/m-p/7857534 */
#target photoshop;
app.bringToFront();
main();
function main(){
if(!documents.length) return;
try{
var Path = activeDocument.path;
}catch(err){
alert("You save your document before running this
...
Copy link to clipboard
Copied
Hey, I thought that I was the only one!
Copy link to clipboard
Copied
No success in the initial few attempts.
Copy link to clipboard
Copied
Ah, yeah, it's that old problem with the forum software changeover where variables in square brackets were lost.
Try this, full credit to @SuperMerlin:
/* https://community.adobe.com/t5/photoshop-ecosystem-discussions/save-all-history-snapshots-as-files/m-p/7857534 */
#target photoshop;
app.bringToFront();
main();
function main(){
if(!documents.length) return;
try{
var Path = activeDocument.path;
}catch(err){
alert("You save your document before running this script!");
return;
}
var doc = app.activeDocument;
var now = doc.activeHistoryState;
var Snaps = snapShotList();
var outputFolder = Folder(Path + "/snapshots");
if(!outputFolder.exists) outputFolder.create();
for (var z in Snaps){
revertNamedSnapshot(Snaps[z]);
var saveFile = File(outputFolder + "/" + Snaps[z].toString().replace(/\./g,'_') + ".jpg");
//var saveFile = File(outputFolder + "/" + Snaps[z].toString().replace(/\./g,'_') + ".psd");
//var saveFile = File(outputFolder + "/" + Snaps[z].toString().replace(/\./g,'_') + ".tif");
SaveForWeb(saveFile,80);
//SavePSD(saveFile);
//SaveTIFF(saveFile);
}
doc.activeHistoryState = now;
};
function SaveTIFF(saveFile){
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.embedColorProfile = true;
tiffSaveOptions.byteOrder = ByteOrder.IBM;
tiffSaveOptions.transparency=true;
tiffSaveOptions.interleaveChannels=true;
tiffSaveOptions.alphaChannels = false;
tiffSaveOptions.imageCompression = TIFFEncoding.NONE;
activeDocument.saveAs(saveFile, tiffSaveOptions, true, Extension.LOWERCASE);
};
function SavePSD(saveFile){
psdSaveOptions = new PhotoshopSaveOptions();
psdSaveOptions.embedColorProfile = true;
psdSaveOptions.alphaChannels = true;
psdSaveOptions.layers = true;
psdSaveOptions.annotations = true;
psdSaveOptions.spotColors = true;
activeDocument.saveAs(saveFile, psdSaveOptions, true, Extension.LOWERCASE);
};
function SaveForWeb(saveFile,jpegQuality) {
var sfwOptions = new ExportOptionsSaveForWeb();
sfwOptions.format = SaveDocumentType.JPEG;
sfwOptions.includeProfile = false;
sfwOptions.interlaced = 0;
sfwOptions.optimized = true;
sfwOptions.quality = jpegQuality;
activeDocument.exportDocument(saveFile, ExportType.SAVEFORWEB, sfwOptions);
};
function snapShotList(){
var doc = app.activeDocument;
var hs = doc.historyStates;
var now = doc.activeHistoryState;
var Name = new Array();
for(var a =0;a <hs.length;a++){
if(hs[a].snapshot) {
doc.activeHistoryState = hs[a];
Name.push(hs[a].name);
}
}
doc.activeHistoryState = now;
return Name;
};
function revertNamedSnapshot(name) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putName( charIDToTypeID('SnpS'), name );
desc.putReference( charIDToTypeID('null'), ref );
executeAction( charIDToTypeID('slct'), desc, DialogModes.NO );
};