Copy link to clipboard
Copied
Hi All,
Request:
1. Need to combine multiple files into one
2. User already created destination doc
3. Folder contains around 30 files(all files having 1 page only)
4. Need to move one by one
Script:
1. Got this script from forum (Combine multiple documents)
2. by using forum script, the output comes wrongly (comes side by side)
Wrong output using below script:
Needed Output:
Modified slightly:
#target indesign
// set the destination document as the active document.
var destination_doc = app.activeDocument;
destination_doc.documentPreferences.allowPageShuffle = true;
destination_doc.spreads[-1].allowPageShuffle = true;
// select the source folder
var sourceFolder = Folder.selectDialog("Select a folder with source InDesign files.");
var fileList = sourceFolder.getFiles();
fileList.sort();
for ( var i = 0; i < fileList.length; i++ ) {
var source_file = fileList;
if ( source_file instanceof File && source_file.name.match(/\.indd$/i)) {
app.open(source_file);
var source_doc = app.open(source_file);
var sourcePages = app.activeDocument.pages.item(0);
sourcePages.duplicate(LocationOptions.AFTER, source_doc.pages.item(0));
sourcePages.move(LocationOptions.AFTER, destination_doc.pages.item(-1));
app.activeDocument.close(SaveOptions.NO);
}
}
Thanks in Advance
Siraj
Hi
you should duplicate/move a spread instead of a page.
try simply modify around L18 - 20 like below.
var source_doc = app.open(source_file);
var sourceSpreads = app.activeDocument.spreads.item(0);
sourceSpreads.duplicate(LocationOptions.AFTER, source_doc.spreads.item(0));
sourceSpreads.move(LocationOptions.AFTER, destination_doc.spreads.item(-1));
app.activeDocument.close(SaveOptions.NO);
thank you
Copy link to clipboard
Copied
Hi
you should duplicate/move a spread instead of a page.
try simply modify around L18 - 20 like below.
var source_doc = app.open(source_file);
var sourceSpreads = app.activeDocument.spreads.item(0);
sourceSpreads.duplicate(LocationOptions.AFTER, source_doc.spreads.item(0));
sourceSpreads.move(LocationOptions.AFTER, destination_doc.spreads.item(-1));
app.activeDocument.close(SaveOptions.NO);
thank you
Copy link to clipboard
Copied
Hi Siraj
Your answers here Re: Pages sticking together after moving to a different document
This is a summary
My post:
I added an extra page before duplicating the odd size page and then I removed the page with myPage.Remove()
Response:
I added a page to the destination document and then deleted it after I was done adding the pages, and it worked!!!
Thank you very much Trevor, you're the man!
In other words use this process (pseudocode)
var tempPage = doc.pages.add();
sourcePage.move / duplicate (etc...);
tempPage.remove();
HTH
Trevor
Copy link to clipboard
Copied
Hi Legends (Milli/Trevor),
First of all., Thank you for spending valuable time for me....
Milli: I tested your code, it is working for me.
Trevor: Still not tested. Hope your code always works well for me.
Again thanks a lot!!!
Copy link to clipboard
Copied
Yep, in your cases milligrams solution is much better