Here’s a script that exports all stories on document pages (i.e. skipping stories on master spreads). It saves the icml files in the documents folders using the document name followed by a number (the numbers look random but are the storyies’ IDs). (Adding functionality to select a book and an output folder is a hassle.)
Peter
[CODE]
(function(){
function exportDocumentStories (doc) {
var stories = doc.stories.everyItem().getElements();
var baseName = String(doc.fullName).replace(/\.indd$/,’ ‘);
for (var i = stories.length-1; i >= 0; i–) {
if (stories[i].textContainers[0].parent instanceof Spread) {
f = File (baseName + stories[i].id + ‘.icml’);
stories[i].exportFile (ExportFormat.INCOPY_MARKUP, f);
}
}
}
function exportICML() {
var chapters = app.activeBook.bookContents.everyItem().getElements();
for (var i = 0; i < chapters.length; i++){
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
app.open (chapters[i].fullName);
exportDocumentStories (app.documents[0]);
app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
}
}
if (app.books.length === 1) {
exportICML();
} else {
alert (‘Open (just) one book.’);
}
}());
[CODE]