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

Script for deleting all Condition Sets

Community Expert ,
Mar 20, 2017 Mar 20, 2017

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.

Screen Shot 2017-03-20 at 1.12.58 PM.png

TOPICS
Scripting

Views

983

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

LEGEND , Mar 20, 2017 Mar 20, 2017

Hi,

Remove all conditions:

app.activeDocument.conditions.everyItem().remove();

Remove all conditions sets:

app.activeDocument.conditionSets.everyItem().remove();

(^/)

Votes

Translate

Translate
LEGEND ,
Mar 20, 2017 Mar 20, 2017

Copy link to clipboard

Copied

Hi,

Remove all conditions:

app.activeDocument.conditions.everyItem().remove();

Remove all conditions sets:

app.activeDocument.conditionSets.everyItem().remove();

(^/)

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
Community Expert ,
Mar 20, 2017 Mar 20, 2017

Copy link to clipboard

Copied

Will this delete the conditions? I need it to delete the Condition Sets.

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
LEGEND ,
Mar 20, 2017 Mar 20, 2017

Copy link to clipboard

Copied

Previous post updated! 

(^/)

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
Community Expert ,
Mar 20, 2017 Mar 20, 2017

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?

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
LEGEND ,
Mar 20, 2017 Mar 20, 2017

Copy link to clipboard

Copied

… and make you a coffee too!

(^/)

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
LEGEND ,
Mar 20, 2017 Mar 20, 2017

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;

(^/)

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
Community Expert ,
Mar 21, 2017 Mar 21, 2017

Copy link to clipboard

Copied

Oh my goodness! That is amazing!!! Thank you so much. Yu have saved my sanity.

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
Community Expert ,
Mar 22, 2017 Mar 22, 2017

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.

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
LEGEND ,
Mar 22, 2017 Mar 22, 2017

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!

(^/)

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
Community Expert ,
Mar 22, 2017 Mar 22, 2017

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.

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
LEGEND ,
Mar 22, 2017 Mar 22, 2017

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!

(^/)

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
Community Expert ,
Mar 22, 2017 Mar 22, 2017

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?

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
LEGEND ,
Mar 22, 2017 Mar 22, 2017

Copy link to clipboard

Copied

LATEST

… Yeap! MacDo and Mickey too!

(^/) 

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