Applying our Photoshop Thumbnail Script to Multiple Documents

by Chadwick Wood
May 25th, 2009

A reader asked if there was a way to apply the Photoshop Thumbnail script I wrote to all open documents, so I figured I'd post it up here for everyone to see. All it takes is a small addition and modification, to iterate through all of Photoshop's open documents, instead of just the active one. Here's the code, with comments:

// docs is a reference to the Documents collection, that holds all open documents
docs = app.documents;

for (i=0; i < docs.length; i++) {
    // instead of getting the active document, iterate through each open doc
    doc = docs.index(i);

    // the rest of the script is unchanged

    var thumbDim = 60; // the dimension of the square

    // crop to a big square, conditionally, based on dimensions
    if (doc.height > doc.width) {
    else {

    // resize, then auto-contrast and sharpen
    // specify that our units are in pixels, via creation of a UnitValue object

    // our web export options
    var options = new ExportOptionsSaveForWeb();
    options.quality = 70;
    options.format = SaveDocumentType.JPEG;
    options.optimized = true;

    var newName = 'thumb-''.jpg';