Copy link to clipboard
Copied
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.
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.
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-- ) {
...
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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#537...
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.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
That depends. With these settings…
…i get the following error on a constant loop, needing a force quit of InDesign:
(at least one assignments file couldn't be found)
Though the assignment file of the first document will get deleted on my hard drive.
------
If i additionally check "ignore errors" in the Batch Converter settings i get this error:
(there are no documents opened)
This quits normally and no files were touched on my hard drive.
Copy link to clipboard
Copied
Could you please post translation of the screenshot in the middle - the one with a long error message?
Copy link to clipboard
Copied
Sure:
At least one of the assignment files could not be found. It was possibly renamed, moved or deleted. Select the missing assignment(s) in the assignments panel and choose "update selected assignments" in the panel menu, to save a replacement at the same location. Or choose the command "change save location for assignment", to save the assignment at a different place.
Copy link to clipboard
Copied
OK, Google Lens to the rescue 😉
I don't know how Peter's script is working - I assume it opens each file separately - but maybe you should close active file yourself at the end of your script?
Or does it closes files automatically?
I think you need to check "Save changed on close"?
Copy link to clipboard
Copied
Sorry, i took too long. 😉
There are no opened docs to be closed, the batch converter works by specifying an input folder and gets to work by itself. It works fine with other scripts, so i think it might have something to do with this particular one. Maybe it's not written as "cleanly" or something. I'm no expert at this stuff, changing already exisiting scripts or merging multiple GREP searches to a list is the extent of my knowledge.
Copy link to clipboard
Copied
Sorry, i took too long. 😉
By @Flo_8580
No need to apologise - I wasn't sure that I can easily translate images - but it looks like it's possible 🙂
If your script is working fine "manually" - then it should definitely work with Peter's script.
What other working scripts do?
Can you try with "Save... " option selected? Of course - test on the copy of your documents 😉
Copy link to clipboard
Copied
Checking "Save changed documents on closing" leads to almost the same outcome as above, only that i don't get the first error on a loop, but a flickering progress bar. Apparently the script tries to continuously edit the first file.
With "ignore errors" checked the result is exactly like above.
Copy link to clipboard
Copied
Can you prepare a sample package - few of your INDD and InCopy files?
@Peter Kahrel, can you make a suggestion what could be wrong?
Copy link to clipboard
Copied
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();
}
}
}());
Copy link to clipboard
Copied
@Peter Kahrel Thanks for the response and fix!
While i saw that part on your website, i apparently misunderstood it. I thought declaring the variables via "var", as was done in the script, would be enough. I didn't saw the extra brackets above and below. As i said, my scripting experience is limited and i didn't write that script. I will test again on monday, when i'm back at work.
@Robert at ID-TaskerI was just testing with simple mockup documents, one dummy textframe on a blank page, saved as an assignment. When i'm back at work i will test Peter Kahrels fix first, after that i can prepare a package of my documents. Let's wait and see. Thanks for your help!
Copy link to clipboard
Copied
@Peter Kahreli just tested your script modification, it works! Thank you!
@Robert at ID-TaskerThis one's solved, thanks for your assistance along the way.
Should any german users stumble upon this thread, you need to change this part from Peter Kahrels fix…
if ( curAssignment.name != "Unassigned InCopy Content" ) {
…back to…
if ( curAssignment.name != "Nicht zugewiesener InCopy-Inhalt" ) {
…like in the original from Kai Rübsamen from the hilfdirselbst forum. Versions for other languages should be changed accordingly.
It doesn't make sense to specify different input/output folders for this action, btw. Just overwrite the original files, as the linked InCopy assignments get deleted and would show up as missing anyway.
Copy link to clipboard
Copied
Go to the link panel, select the IC link and embedd it.
Copy link to clipboard
Copied
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.