This script works in InDesign CS6, at least. It removes all unused paragraph and character styles with one click. Sweet:
var myDoc = app.activeDocument;
var myParStyles = myDoc.paragraphStyles;
var myCharStyles = myDoc.characterStyles;
for (j = myParStyles.length-1; j >= 2; j– ) {
removeUnusedParaStyle(myParStyles[j]);
}
for (i = myCharStyles.length-1; i >= 1; i– ) {
removeUnusedCharStyle(myCharStyles[i]);
}
function removeUnusedParaStyle(myPaStyle) {
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences.appliedParagraphStyle = myPaStyle;
var myFoundStyles = myDoc.findText();
if (myFoundStyles == 0) {
myPaStyle.remove();
}
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
}
function removeUnusedCharStyle(myChStyle) {
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
app.findTextPreferences.appliedCharacterStyle = myChStyle;
var myFoundStyles = myDoc.findText();
if (myFoundStyles == 0) {
myChStyle.remove();
}
app.findTextPreferences = NothingEnum.nothing;
app.changeTextPreferences = NothingEnum.nothing;
}
This is where I found it, just in case I didn’t copy it correctly:
https://forums.adobe.com/message/1106498