Copy link to clipboard
Copied
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" + m
...
Copy link to clipboard
Copied
Hello @Adeprimo
Here you go...
doc = app.activeDocument;
var docPages = doc.pages;
var fileName = doc.name.replace(/.indd$/i, "");
for(p=0;p<docPages.length;p++){
var myPageName = docPages[p].name;
var myIDML = new File(File(doc.filePath).fsName + "/" + fileName + "_P" + myPageName + ".idml");
doc.exportFile(ExportFormat.INDESIGN_MARKUP, myIDML);
}
alert("Done exporting idml files!")
Regards,
Mike
Copy link to clipboard
Copied
Thanks Mike, I will test it.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks so much Mike.
It's working now.
Copy link to clipboard
Copied
I have to say Mike, Thank you!
You are a javascript GOD.
Copy link to clipboard
Copied
Is there a way to generate unique file names for each of the exported pages based on the content on each page? I.e. I have 500 business cards that need unique INDD files but it would be nice if it could pull the name from the card as the file name. Not sure if that is possible.