• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

combine multiple files into one

Enthusiast ,
May 31, 2015 May 31, 2015

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:

Screen Shot 2015-05-31 at 8.05.38 PM.png

Needed Output:

Screen Shot 2015-05-31 at 8.08.48 PM.png

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

TOPICS
Scripting

Views

1.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , May 31, 2015 May 31, 2015

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

Votes

Translate

Translate
Contributor ,
May 31, 2015 May 31, 2015

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 31, 2015 May 31, 2015

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 31, 2015 May 31, 2015

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!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jun 01, 2015 Jun 01, 2015

Copy link to clipboard

Copied

LATEST

Yep, in your cases milligrams solution is much better

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines