Copy link to clipboard
Copied
I have a book of about 30 documents. Each document contains the same Condition Sets. But I need to clean out and update all the condition sets. I don't want to have to do this manually on every single document, but rather, just do it in one document, and then sync the settings to all the other documents. But unlike Condition Names, there is no way to select multiple Condition Sets at once, So if I need to delete some condition sets, I have to do it manually for every single chapter.
So I'm looking for a script that will delete all the condition sets in the entire document.
Can anyone assist? Please note that I am not a scripter, nor looking to become one. I just need to use a script. And I'm hoping that one of you nice folks can write it for me. Any help is greatly appreciated!
Here is a screenshot of all the conditions Sets that I currently need to edit.
Hi,
Remove all conditions:
app.activeDocument.conditions.everyItem().remove();
Remove all conditions sets:
app.activeDocument.conditionSets.everyItem().remove();
(^/)
Copy link to clipboard
Copied
Hi,
Remove all conditions:
app.activeDocument.conditions.everyItem().remove();
Remove all conditions sets:
app.activeDocument.conditionSets.everyItem().remove();
(^/)
Copy link to clipboard
Copied
Will this delete the conditions? I need it to delete the Condition Sets.
Copy link to clipboard
Copied
Previous post updated!
(^/)
Copy link to clipboard
Copied
Would it be possible to also add a line to that script at the beginning to delete all unused conditions?
Copy link to clipboard
Copied
… and make you a coffee too!
(^/)
Copy link to clipboard
Copied
var myDoc = app.activeDocument,
myConditions = app.activeDocument.conditions,
C = myConditions.count();
myDoc.conditionSets.everyItem().remove();
for ( c = C-1; c >= 0; c-- ) removeUnusedConditions(myConditions
);
function removeUnusedConditions(myCondition) {
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.appliedConditions = [myCondition];
myFound = myDoc.findGrep();
if (myFound == 0) myCondition.remove();
}
app.findGrepPreferences = null;
(^/)
Copy link to clipboard
Copied
Oh my goodness! That is amazing!!! Thank you so much. Yu have saved my sanity.
Copy link to clipboard
Copied
Well, I ran into a bit of an issue. The script doesn't have the same result as the manually selecting all unused conditions. The script actually selects all Hidden conditions and deletes them. So if there is text and anchored objects with that condition applied, the condition is simply deleted and the condition removed, thus making Unconditional all the text had had conditions applied, to it.
Copy link to clipboard
Copied
Kelly,
If you hide a condition and try to find something with this condition, you won't find nothing! [totally normal!]
So, you need to make the conditions "visible"!
We could play it as: Keep in mind what conditions are hidden, make all visible, remove unused ones and finally hide previously hidden conditions!
(^/)
Copy link to clipboard
Copied
True, but I manually go to select all unused conditions, just the unused conditions are selected. So even if conditions are hidden, InDesign knows the difference between hidden and unused. What I need is the same behavior as what I can get through the flight menu when I choose Select All Unused. It looks like your new suggestion would accomplish that.
Copy link to clipboard
Copied
var myDoc = app.activeDocument,
myConditions = app.activeDocument.conditions,
C = myConditions.count();
myDoc.conditionSets.everyItem().remove();
for ( c = C-1; c >= 0; c-- ) {
if (myConditions
.visible == false) { myConditions
.visible = true; removeUnusedConditions(myConditions
); if (myConditions
.isValid) myConditions .visible = false; }
else removeUnusedConditions(myConditions
); }
function removeUnusedConditions(myCondition) {
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.appliedConditions = [myCondition];
myFound = myDoc.findGrep();
if (myFound == 0) myCondition.remove();
}
app.findGrepPreferences = null;
If next time, you offer me a coffee!
(^/)
Copy link to clipboard
Copied
Sure thing! I don't know what kind of coffee shops there are in France. I offer you a Starbucks gift card, but I'm not sure if there are Starbucks in France! Are there?
Copy link to clipboard
Copied
… Yeap! MacDo and Mickey too!
(^/)