Answered
Export InDesign document to separate IDML files?
Does anyone have a InDesign script that exports a multi-page InDesign document to separate IDML files?
Does anyone have a InDesign script that exports a multi-page InDesign document to separate IDML files?
Hello @Adeprimo,
I should have tested my JUNK code before I posted it as it doesn't work...it was early and i didn't have any coffee yet.
Try the code below for your needs, it's kinda convoluted but it works!!
var doc = app.activeDocument;
var myFolder =doc.filePath;
var fileName = doc.name.replace(/.indd$/i, "");
var myPages = app.activeDocument.pages;
for (i = 0; i < myPages.length; i++){
var myPageName = myPages[i].name;
doc.saveACopy(File(myFolder + "/Temp_P" + myPages[i].name + ".indd"));
tempDoc = app.open(File(myFolder + "/Temp_P" + myPages[i].name + ".indd"), false);
doc.pages[i].duplicate(LocationOptions.AT_END, tempDoc.pages[-1]);
tempDoc.pages.itemByRange(tempDoc.pages[0], tempDoc.pages[-2]).remove();
var myIDML = new File(File(doc.filePath).fsName + "/" + fileName + "_P" + myPageName + ".idml");
tempDoc.exportFile(ExportFormat.INDESIGN_MARKUP, myIDML);
tempDoc.close(SaveOptions.NO);
var tempDoc = File(myFolder.fsName + "/Temp_P" + myPageName + ".indd");
tempDoc.remove();
}
alert("Done exporting idml files!")
Regards,
Mike
Already have an account? Login
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.