Skip to main content
Inspiring
January 24, 2025
Answered

Easy way to clean InCopy content from book file?

  • January 24, 2025
  • 2 replies
  • 1289 views

Hello,

 

i'm looking for a solution to unlink all InCopy stories and delete all assignments from an InDesign book after production. Because we might reuse a portion of the content in other publications, which leads to a few challenges…

 

a) We might have to change the textflow because of different font stylings in the other publication, but of course want to keep the original unchanged.

 

b) It trips up designers who don't pay attention to the Assignments panel, as copying assigned stories to a different document hides them in the "Unassigned Content" region of the panel. So they are wondering why they can't edit the text.

 

We have our publication set up as one double page spread per InDesign document, so multiple designers can edit different parts of the publication, all collected in one InDesign book file for the whole issue. Opening each page and manually unlinking/deleting all InCopy content would be tedious. Is there a script or other method which would help with this?

 

Thanks.

Correct answer Peter Kahrel

@Flo_8580

 

Can you prepare a sample package - few of your INDD and InCopy files?

 

@Peter Kahrel, can you make a suggestion what could be wrong?

 


@Flo_8580 

As described on the script's web page, you should wrap your script in/as an anonymous function. This one should work:

 

(function () {
  
  var allAssignments = app.activeDocument.assignments;

  for ( var i = allAssignments.length-1; i >= 0 ; i-- ) {
    // the current assignment
    var curAssignment = allAssignments[i];
    // alle content of the assignment
    var allLinkedStories = curAssignment.assignedStories;
    for ( var j = allLinkedStories.length-1; j >= 0 ; j-- ) {
      // the current content
      var curLinkedStory = allLinkedStories[j];
      // the link …
      var storyLink = curLinkedStory.storyReference.itemLink;
      // … unlinking
      storyLink.unlink();
    }
    // delete assignment
    if ( curAssignment.name != "Unassigned InCopy Content" ) {
      curAssignment.remove();
    }
  }

}());

2 replies

Willi Adelberger
Community Expert
Community Expert
January 24, 2025

Go to the link panel, select the IC link and embedd it. 

Flo_8580Author
Inspiring
January 24, 2025

This would be essentially the same as copying a linked story and unlinking it afterwards in the new document. That's what we're doing at the moment.

I'd like to strip all InCopy content from our documents in one go after the issue went to the printer, if possible.

Robert at ID-Tasker
Legend
January 24, 2025

If you work on Windows - my ID-Tasker tool could do this and a lot more - but isn't free.

 

Or here is a free/donation solution from @Peter Kahrel

 

https://creativepro.com/files/kahrel/indesign/batch_convert.html

 

You would also need a simple JS script that would be executed on each file - I'll try to prepare something later today - I'm on my phone right now - or someone else might be quicker with a working code.

 

Flo_8580Author
Inspiring
January 24, 2025

We're on Macs (and getting our bosses to pay for addons would be another issue).

 

I looked at Peter Kahrels converter, running a script on a bunch of documents would be a first step. Thanks for the tip!

Flo_8580Author
Inspiring
February 28, 2025

So, some time later i've made some progress. I actually found a script to clean documents of InCopy content on this (german) forum:

https://www.hilfdirselbst.ch/foren/InCopy__icml-Verkn%FCpfungen_per_Skript_aufheben_P537065.html#537065

I don't know if this will work on non german InDesign versions, as it refers to the german spelling of "Unassigned InCopy Content" of the assignments panel. So i made a quick translation, i can't test if this will work though:

 

// all assignments in document
var allAssignments = app.activeDocument.assignments;

for ( var i = allAssignments.length-1; i >= 0 ; i-- ) {
  // the current assignment
  var curAssignment = allAssignments[i];
  // alle content of the assignment
  var allLinkedStories = curAssignment.assignedStories;
  for ( var j = allLinkedStories.length-1; j >= 0 ; j-- ) {
    // the current content
    var curLinkedStory = allLinkedStories[j];
    // the link …
    var storyLink = curLinkedStory.storyReference.itemLink;
    // … unlinking
    storyLink.unlink();
  }
  // delete assignment
  if ( curAssignment.name != "Unassigned InCopy Content" ) {
    curAssignment.remove();
  }
}

 

But this has at least solved the first half of my problem, cleaning a document is only a single click now. Sadly, this script won't work with Peter Kahrels Batch Converter, so i still have to open each document manually.