• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script to export snapshots as JPEG with the snapshot names?

Community Expert ,
Apr 18, 2024 Apr 18, 2024

Copy link to clipboard

Copied

Is there any script to save time by exporting all saved snapshots as separate files using snapshot names?

TOPICS
Actions and scripting

Views

62

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 19, 2024 Apr 19, 2024

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
...

Votes

Translate

Translate
Adobe
Community Expert ,
Apr 18, 2024 Apr 18, 2024

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 18, 2024 Apr 18, 2024

Copy link to clipboard

Copied

No success in the initial few attempts.

no luck.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2024 Apr 19, 2024

Copy link to clipboard

Copied

LATEST

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 );  
};  

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines