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.
KalFebruary 27, 2015 4:09 pm
Thanks 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)
AdminFebruary 27, 2015 4:49 pm
Hi 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 AldairiMarch 25, 2015 12:10 pm
This is awesome but i need the code that clear cell style override can you help me with is please?
Thanks
AdminMarch 25, 2015 5:56 pm
Hi 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 AldairiJanuary 13, 2016 12:28 pm
Sorry 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
BrianDecember 4, 2015 12:01 am
Replying to Admin, the clearCellStyle works! Thanks.
LsJuly 20, 2016 2:02 pm
great resource, thanks
AnnaMarch 16, 2018 5:07 pm
Thank you, this is very helpful.
What is the code for clearing character styles?
ArielMarch 16, 2018 5:16 pm
Hi 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
DianeJuly 6, 2018 4:44 pm
Is 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.
ArielJuly 6, 2018 5:03 pm
Hi 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
JulianneOctober 4, 2018 8:19 pm
This saved my [project’s] life. Thank you!!!!
ArielOctober 8, 2018 4:23 pm
Very glad to hear it! Thanks Julianne 🙂
JamieMOctober 8, 2018 7:40 pm
Ariel-
Any way to have this activated on Place?
ArielOctober 10, 2018 3:40 pm
Hi 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 pm
Thank you for this Ariel, it works great ! Would it be possible to also include object styles in it ?
ArielJanuary 4, 2019 4:21 pm
Hi 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 VaheedJanuary 15, 2020 10:37 pm
Hi
Is it possible to point to clear overrides from exact paragraph style?
This will clear overrides from all styles right?
ArielJanuary 21, 2020 12:20 am
Hi 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…
EmmanuelleFebruary 3, 2020 12:15 pm
Hello,
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
ArielFebruary 3, 2020 4:12 pm
Hi 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.
EmmanuelleFebruary 3, 2020 6:29 pm
Hi 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
ArielFebruary 11, 2020 12:18 am
Yes, 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!
EmmanuelleFebruary 12, 2020 1:48 pm
Hi 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
hirooberFebruary 23, 2020 8:43 am
I’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.
ArielFebruary 28, 2020 4:52 pm
The 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 CarrilhoMay 29, 2020 4:24 pm
Wow.
I was affraid (Even made a save as new ind file)
Mr Timothy Ariel Walden, Sir: Thank You
ArielMay 31, 2020 3:26 pm
Thank you Álvaro. Glad it helped!
Viktor TombakJuly 2, 2020 12:02 pm
Thank 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!
ArielJuly 5, 2020 10:41 pm
Great, I appreciate the feedback!
JoeAugust 20, 2020 5:38 pm
Thanks 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.
ArielOctober 21, 2020 12:54 am
Good feature request! I’ll see if I can add it at some point.
Ariel
barbaraSeptember 25, 2020 1:24 am
Exactly what what Viktor said. Thank you so much from me as well!