Skip to main content
April 12, 2024
解決済み

Script: Delete Empty Style Groups

  • April 12, 2024
  • 返信数 1.
  • 201 ビュー

Hello,

I would like to go through my style groups (character, paragraph, object, etc.) in order to remove empty groups and subgroups. To count the number of styles in a group, it seems that a number count() property exists, but I can't seem to put it into practice.

Does anyone have any advice on this?

このトピックへの返信は締め切られました。
解決に役立った回答 rob day

Hi @35626004 This would remove empty ParagraphStyleGroups:

 

var psg = app.activeDocument.paragraphStyleGroups.everyItem().getElements()
for (var i = 0; i < psg.length; i++){
    //count() or length works
    if (psg[i].paragraphStyles.count() == 0) {
        psg[i].remove()
    } 
}; 

返信数 1

rob day
Community Expert
rob dayCommunity Expert解決!
Community Expert
April 12, 2024

Hi @35626004 This would remove empty ParagraphStyleGroups:

 

var psg = app.activeDocument.paragraphStyleGroups.everyItem().getElements()
for (var i = 0; i < psg.length; i++){
    //count() or length works
    if (psg[i].paragraphStyles.count() == 0) {
        psg[i].remove()
    } 
};