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

merge multiple indd docs into one without any dialog (cs6)

Participant ,
Jun 08, 2015 Jun 08, 2015

I need script which can merge/combine multiple indesign files into one indd doc, but without any dialog like missing fonts etc?

I simply cant manually move pages from doc to doc....

tnx

i have this script but have error

Untitled-1.png

// DESCRIPTION: Mass combine a bunch of indd files into one.

// 6 July 2013

// INSTRUCTIONS

// Put all the files you want to combine into one document in a folder, named in the order

// you want them to appear in the book (e.g. "001.indd", "002.indd", etc. or something) so

// they appear correctly when sorted by name in finder/explorer.

#target indesign

app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

// set the destination document as the active document.

var destination_doc = app.activeDocument;

// select the source folder

var sourceFolder = Folder.selectDialog("Select a folder with source InDesign files.");

// if we're not in the source folder, stop running the script.

if ( !sourceFolder ) {

  exit(0);

}

// set file list and run through each file. Sorting them alphanumerically.

var fileList = sourceFolder.getFiles();

fileList.sort();

// run through each file

for ( var i = 0; i < fileList.length; i++ ) {

  var source_file = fileList;

  // making sure it's an indesign file...

  if ( source_file instanceof File && source_file.name.match(/\.indd$/i)) {

  app.open(source_file);

  var source_doc = app.documents.item(source_file.name);

  var sourcePages = source_doc.pages.item(0);

  // break the master page items so they can be moved onto the new document.

  var masterItems = sourcePages.masterPageItems;

  if ( masterItems.length > 0 ) {

  for ( var j=0; j<masterItems.length; j++ ) {

  masterItems.override(sourcePages);

  }

  }

  // removing the applied master (this can mess up some files if not done)

  sourcePages.appliedMaster=null;

  // duplicating it in the original file (due to errors) and them moving it to

  // the destination document.

  sourcePages.duplicate(LocationOptions.AFTER, source_doc.pages.item(0));

  sourcePages.move(LocationOptions.AFTER, destination_doc.pages.item(-1));

  // closes the file that was opened without saving (to avoid memory problems)

  app.activeDocument.close(SaveOptions.NO);

  }

}

TOPICS
Scripting
1.1K
Translate
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 ,
Jun 09, 2015 Jun 09, 2015

Hi kajzica

The error which is seen on your screenshot is not just a missing font. It is a real error which prevents the script from going on.

I guess that there is a problem with one of the files.

if you open a file from within InDesign it then will become the activeDocument. So you may write

var scource_doc = app.activeDocument;

instead of


var source_doc = app.documents.item(source_file.name);

But that is not the problem.

Every InDesign file has at least one page. So there must be an other error. I guess with one of the files in your array.

kind regards

Daniel (from Switzerland)

Translate
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
Advisor ,
Jun 09, 2015 Jun 09, 2015
LATEST

that error is created by this wierd onstruct:

  app.open(source_file);

  var source_doc = app.documents.item(source_file.name);

replace with:
     var source_doc=app.open(source_file);

The

app.scriptPreferences.userInteractionLevel=UserInteractionLevels.NEVER_INTERACT

should have taken care of missing fonts dialogs and stuff like that, unfortunately it seems to give strange results with the new TypeKit dialog.

Translate
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