I was recently needing a way to clear all overrides in a 100+ page book. The book was divided into many separate stories, so it was not possible to simply “select all” and click on the “Clear overrides” button.
Instead of going through each story in turn, selecting all the text there, clearing overrides, and repeating that for each story in the document, I wrote a quick script.
(In fact, if it is necessary to clear all local overrides in footnotes it can be even more time-consuming, as there is no way to select all footnotes in one go. Rather, it would be necessary to clear the overrides one footnote at a time – although if the footnotes have a paragraph style applied then there is a shortcut for doing this.)
The script below will clear all paragraph-level and character-level overrides in the active InDesign document.
To use, simply copy the script into your favorite text editor, save with a .jsx extension, and place into your InDesign Scripts folder.
// Clear All Overrides // Written by TAW. (c) 2014 by Bookraft Solutions, Israel (Id-Extras.com) // Please do not delete this copyright notice. // var myOverrideType = OverrideType.ALL; // var myOverrideType = OverrideType.CHARACTER_ONLY; // var myOverrideType = OverrideType.PARAGRAPH_ONLY; var allStories = app.activeDocument.stories.everyItem(); // Remove overrides from all stories try{ allStories.clearOverrides(myOverrideType); } catch (e){alert ("No stories!")} // Remove overrides from all footnotes try{ allStories.footnotes.everyItem().texts.everyItem().clearOverrides(myOverrideType); } catch (e){alert ("No footnotes!")} // Remove overrides from all table try{ allStories.tables.everyItem().cells.everyItem().paragraphs.everyItem().clearOverrides(myOverrideType); } catch (e){alert ("No tables!")} alert("Overrides cleared!");
As is, the script will clear all overrides throughout the document from all text, including all text in tables and footnotes. It will clear paragraph-level overrides as well as character-level overrides.
However, it is easy enough to modify the script to suit your needs.
First of all, if you need to clear only paragraph-level overrides, or only character-level overrides, simply comment out the relevant line: Of lines 7, 8, and 9, exactly two should be commented out. (I may add a UI if I get the chance.)
Then, if you do not need to delete overrides from tables, footnotes, or regular text, comment out the appropriate lines there too. It should be self-evident how to do this, but if you have a question, leave a comment below.
Clark Kenyon
February 8, 2023 10:54 pmI’m working on a book layout. The original manuscript in Word is full of direct formatting (e.g., “Normal+Italic”). I changed all the italics in that document to a single character style (Italic), but apparently this did not catch all the original TNR italics. I noticed this when I placed the Word doc in my ID template. I tried this script on the InDesign layout, and it worked ok, but instead of removing the TNR overrides in the footnotes, it just removed all of the italic styling.
Ariel
February 8, 2023 11:29 pmHi Clark,
It will remove all overrides – so anything that doesn’t have a specific character style will be removed. I guess somehow that was the case with the italics styling?
Ariel
Clark Kenyon
February 11, 2023 1:19 amYou’re right. The overridden text did not have a specific italic styled applied to it.
Nicole Nicolas
December 29, 2022 6:31 pmHi, is it possible to prevent this from working on master pages? Sometimes I have text on a master page that isn’t linked to a paragraph style, like a title for a cover page, and it’s not overridden in the document, just sitting on the master page. Can I prevent it from changing that?
Ariel
January 8, 2023 11:02 pmHi Nicole,
I’ve played around a little with your idea, but there isn’t a simple way of doing this while keeping the script structure the same.
The point is that in the script above, all stories are collected as what is known as an InDesign “collection,” meaning that an operation can be performed on all the stories in the collection in one go, without having to loop through each story.
This keeps the script quick and simple.
You’re wanting to filter out any stories originating on master pages. It’s definitely not difficult to do, but it means turning the collection of stories into an array of stories and looping through each one individually, filtering out the master-page ones.
Easy to do, but it’s quite a different script. If I get a chance, I will post an update, or an alternative script, that does this, when I get a chance…
Sarah
March 4, 2022 2:01 pmHi Ariel
I’m working on a long document and would LOVE a script to clear only overrides on all Footnotes only, so they just use the paragraph and characters styles applied to them. I think your script will do this, but I’m hopeless at code and can’t get this to work when I edit it myself. Can you please help me?
Ariel
March 4, 2022 2:09 pmHi Sarah,
I think this should help: https://www.id-extras.com/apply-paragraph-style-footnotes/
It will clear overrides from footnotes as well as applying a specific paragraph style to them all.
Ariel
David
January 4, 2022 9:48 pmHi Ariel
Reporting what happened:
I needed to clear override only on paraghraph styles (because I was not using any character style nor cells or tables or footnotes), so I commented this line:
//var myOverrideType = OverrideType.ALL;
and enabled this line:
var myOverrideType = OverrideType.PARAGRAPH_ONLY;
however that did not work.
So I tried using your script exactly as you coded it. That worked perfectly.
Ariel
January 4, 2022 10:13 pmHi David,
The script, as is, will clear overrides from all paragraphs, footnotes, and tables in the document, and it will clear both the paragraph-level overrides (i.e., it will reset the indents, space before, space after) as well as character-level overrides (e.g., if you’ve made a single word inside a paragraph italics without using a character style).
You can change this behaviour by uncommenting the line that defined the OverrideType, so you can make it clear only char-level overrides, or only para-level overrides.
But in all cases it will attempt to clear the overrides from all text, footnotes, and tables.
If the document does not have footnotes or tables, though, no worries, it won’t break the script (because of the try…catch thing).
So as you say, in your case the script just works, and it would not be necessary to make any modifications.
Doruk Üvez
August 6, 2021 3:21 pmHi Ariel,
This script works clean as a whistle. I just wanted to ask can we clear overrides page by page? I mean I don’t want to clear overrides for whole document. How can we do that?
Ariel
August 6, 2021 5:31 pmHi Doruk,
It could be easily modified to work text frame by text frame. (Page by page is perhaps a little more difficult.) Would that help?
Ariel
Doruk Üvez
August 7, 2021 11:15 amHi Ariel,
Thanks for the reply. I am new at scripting. How can I modify it for text frame?
Ariel
August 17, 2021 11:34 amTry replacing the line that begins
line to:
I haven’t tested this, but if it works, it will work on all text frames on the active (visible) spread only.
HTH,
Ariel
Jeff
February 18, 2021 4:33 amAriel, thank you for the information on overrides. I need to “override” a number of text frames on a bunch of pages that are automatically pulled down by my scripts. I essentially need to simulate the “command/shift” click on the document pages to “unlock” or override those items so I can fill them with data.
Any idea how to do this?
Ariel
March 5, 2021 2:05 amHi Jeff,
Your question is kind of unrelated to the script here.
Scripting the equivalent of “shift-clicking” a page item isn’t quite as intuitive as one would have thought.
A better place for this question would be on the Forum, here: http://id-extras.com/forum/index.php
Perhaps you’d like to repost there?
Thanks,
Ariel
barbara
September 25, 2020 1:24 amExactly what what Viktor said. Thank you so much from me as well!
Joe
August 20, 2020 5:38 pmThanks for this – really need it to clear all Object styles throughout the document as sometimes when I relink to a folder of spreadsheets it basically overrides the object style every time, so I have to manually select them and clear them one by one.
Ariel
October 21, 2020 12:54 amGood feature request! I’ll see if I can add it at some point.
Ariel