I found another script that does delete paragraph, character and object styles that are NOT located in group folders and preserves the formatting. Is there code that can be added to remove styles that are contained IN group folders and preserve formatting?
Here is the script:
#target InDesign
myDoc = app.activeDocument;
var chs1 = myDoc.characterStyles.length;
for(var j=chs1-1; j>0; j--) //j++ replaced here by j--
{
myDoc.characterStyles[j].remove();
};
var pghs1 = myDoc.paragraphStyles.length;
for(var i=pghs1-1; i>0; i--) //j++ replaced here by j--
try {
myDoc.paragraphStyles[i].remove();
}
catch(e){} ;
var objs1 = myDoc.objectStyles.length;
for(var n=objs1-1; n>0; n--) //j++ replaced here by j--
{
myDoc.objectStyles[n].remove();
};