… all I really need is a macro/action that simply sends the four commands Shift-Cmd-S, Enter, Cmd-R, Cmd-W that I can run over and over until all the windows are closed. I can probably figure out how to do that myself sometime.
InDesign doesn't support macros and/or actions. And boy! is that high on my wish-list! Exactly for doing stuff like this. Now it needs a script.
The scripting language does not 'record' actions — it works the other way around, you have to supply the commands that are performed inside ID when you press 'Shift+Cmd+S'. So you would send a 'save as', then a 'close' command to the active window, repeating until no windows are left.
What happens when you have an untitled document? In the javascript below, I check for that and don't do nuffin' with these.
list = app.documents.everyItem().getElements();
while (list.length > 0)
{
doc = list.pop();
if (doc.saved)
{
doc.save (doc.fullName,false,undefined,true);
doc.close();
}
}