Script Description
This script allows you to flatten all the documents open in Photoshop at once.
Looking at the script
The script first checks to see if there are any open documents. If there aren't, then the script displays an alert. If there are open documents then it will loop through all of them flattening the files as it goes.
// This script will flatten all open documents in Photoshop
// ensure that there is at least one document open; if not, display error message
if (documents.length == 0) { alert("There are no documents open."); }
else {
myTotalDocs = (documents.length - 1);
for ( i = 0; i <= myTotalDocs; i++ ) //This loop will keep pages in order, with the last page on top
{
myDocument = app.documents[i];
app.activeDocument = myDocument;
myDocument.flatten();
}
}
Installing the script
Installing this script, or any Photoshop script is really easy. Just place the .js or .jsx file into the scripts folder within your Photoshop application folder. Such as, C:\Program Files\Adobe\Adobe Photoshop CS3\Presets\Scripts. You may need to restart the application to see the script.
Download the MassFlatten Script

