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.
Kal
February 27, 2015 4:09 pmThanks for this. There seems to be an error in the script though. I could only get it to work in CS6 by changing the start of line 27 to:
allStories.tables.everyItem() …
(i.e. delete the first instance of ‘.everyItem()’ on that line)
Admin
February 27, 2015 4:49 pmHi Kal,
You’re quite right. That first everyItem() is redundant since the everyItem() already appears on line 11.
Thanks for pointing this out. I’ve fixed it up.
Abdulla Aldairi
March 25, 2015 12:10 pmThis is awesome but i need the code that clear cell style override can you help me with is please?
Thanks
Admin
March 25, 2015 5:56 pmHi Abdulla,
If you add the following lines, I think it should work to clear all cell styles:
// Remove overrides from all cells
try{
allStories.tables.everyItem().cells.everyItem().clearCellStyleOverrides(true);
}
catch (e){alert (“No tables!”)}
I haven’t had a chance to actually test this, so let us know.
Abdulla Aldairi
January 13, 2016 12:28 pmSorry for the delay of the reply and Irally appreciate your help many thanks and i am looking for one script more than 2 years and still cannot find it i want script that fit text in selection column if you can help me with this pleaseeeeees
Thanks in advance
Brian
December 4, 2015 12:01 amReplying to Admin, the clearCellStyle works! Thanks.
Ls
July 20, 2016 2:02 pmgreat resource, thanks
Anna
March 16, 2018 5:07 pmThank you, this is very helpful.
What is the code for clearing character styles?
Ariel
March 16, 2018 5:16 pmHi Anna,
Do you mean character styles and NOT paragraph styles?
In any case, the 3 options are these:
You’ll find those lines at the beginning of the script. I think they’re self-explanatory.
So, choose which is the option you want, and uncomment it (that is, delete the // at the beginning of the line), and comment-out the other 2 lines (that is, add // at the beginning of them).
HTH,
Ariel
Diane
July 6, 2018 4:44 pmIs there a way to skip locked stories? I have InCopy stories in documents I’m this script on, and I don’t want to override those for various reasons. The script doesn’t work unless I check out the story or cut it, run the script and then paste it back. The stories cover multiple pages, so that isn’t as easy as it sounds. Would be great if there was an option to skip locked stories so that the script would go ahead and run on the available text and ignore the unavailable text.
Ariel
July 6, 2018 5:03 pmHi Diane,
It would mean changing quite a lot in the script. Currently, it uses a quick workaround to remove overrides from all stories. If it were to skip the locked ones, the script would need to be rewritten somewhat.
Ariel
Julianne
October 4, 2018 8:19 pmThis saved my [project’s] life. Thank you!!!!
Ariel
October 8, 2018 4:23 pmVery glad to hear it! Thanks Julianne 🙂
JamieM
October 8, 2018 7:40 pmAriel-
Any way to have this activated on Place?
Ariel
October 10, 2018 3:40 pmHi Jamie,
It could probably be done with an on-place event listener, but it’s not something I would normally want to do because the likelihood of deleting local formatting that has been applied in Word and is meant to be preserved is high. Who gets a properly and consistently styled document in Word? It’s never happened to me yet!
Simon S.
October 30, 2018 2:29 pmThank you for this Ariel, it works great ! Would it be possible to also include object styles in it ?
Ariel
January 4, 2019 4:21 pmHi Simon,
Object styles are a little more complicated, perhaps, because they’ve got 2 sorts of overrides — some categories of properties in object styles can be kept as “undefined,” so they don’t affect the object one way or another. That’s why there are those 2 “clear overrides” buttons in the object style panel (I always find it a bit confusing — it is quite confusing!).
So it would need looking into. But yet, it could be done.
Taqi Vaheed
January 15, 2020 10:37 pmHi
Is it possible to point to clear overrides from exact paragraph style?
This will clear overrides from all styles right?
Ariel
January 21, 2020 12:20 amHi Taqi,
Correct, this script clears the overrides from the entire document.
Clearing overrides from a specific paragraph style is, of course, possible, but it would be a different script.
But it’s also possible in InDesign, as you probably know: Do a find/change that searches for style X and replaces it with style X. Click on Change All, and this will clear all overrides from that paragraph style through the story or document or selection…
Emmanuelle
February 3, 2020 12:15 pmHello,
Thanks for creating this script, this might be very useful indeed!
However, I have a problem : InDesign CC 2020 tells me there is a syntax error when I try to run it on a document :
“Error n°8
Syntax error
Line : 16
Source : catch (e){alert («No stories!»)}
Incorrect text : «
(On my computer, InDesign is in french, just in case it is important).
Best regards
Emmanuelle
Ariel
February 3, 2020 4:12 pmHi Emmanuelle,
Somehow, it seems that when you copied the script from the website, the straight quotes ” got changed to guillemets.
I think if you change them back to straight quotes it should all work.
Emmanuelle
February 3, 2020 6:29 pmHi Ariel,
Thanks a lot! It is just fine!
I see why the quotes changed and I will be more careful ( I copied and pasted the code elsewhere than in the notepad so… :/).
Is it possible to add a cell formatting override in this particular script (with a cell style, not a paragraph style)?
Best
Emmanuelle
Ariel
February 11, 2020 12:18 amYes, it is possible. If you look back to my answer to Abdulla dated 25 March 2015 (time flies!) you’ll see how to do it!
Emmanuelle
February 12, 2020 1:48 pmHi Ariel,
Yes, sorry to bother you with this.
I thought I had already put this part you gave him but no, of course…
… And that is why I don’t create scripts myself :/.
Thank you for your time 🙂
Emmanuelle
hiroober
February 23, 2020 8:43 amI’m desperate with the task of clearing out all the local styles on hundreds of footnotes in a long document, and I thought I found the perfect solution when I stumbled on this script. Tried it, didn’t work in ID2019. It ran without any problem and I got the message of “Overrides cleared”. But those local styles are still on all of my footnotes. I also read all the comments above just in case I missed anything, including the potential quotes issue, but no, I pasted in a fresh new notepad and saved it to jsx. My heart was broken, I sooooo wish this works.
Ariel
February 28, 2020 4:52 pmThe script works fine to clear out local overrides from all footnotes in the document. “Local overrides” means special formatting that is applied without using a character style. But you mention “local styles.” That sounds like special formatting applied with a character style. This script does not remove character styles from anything, only local overrides…
Álvaro Carrilho
May 29, 2020 4:24 pmWow.
I was affraid (Even made a save as new ind file)
Mr Timothy Ariel Walden, Sir: Thank You
Ariel
May 31, 2020 3:26 pmThank you Álvaro. Glad it helped!
Viktor Tombak
July 2, 2020 12:02 pmThank you so much, Ariel! Worked perfectly for me in various modifications — for the stories as well as for the footnotes. Saved a LOT of time. Fantastic job!
Ariel
July 5, 2020 10:41 pmGreat, I appreciate the feedback!
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
barbara
September 25, 2020 1:24 amExactly what what Viktor said. Thank you so much from me as well!
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
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
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.
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
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…
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.