swatchGroups - ExtendScript/wiki GitHub Wiki

This snippet shows how to remove empty Swatch Groups, as they are notated in Illustrator CC documentation:

var doc = app.activeDocument; // get the doc

// loop all groups and remove the empty ones
for (var i = doc.swatchGroups.length - 1; i >= 0; i--) {
	//    alert(doc.swatchGroups[i].getAllSwatches())
	if (doc.swatchGroups[i].getAllSwatches() == "") {
		//$.writeln('group "' + doc.swatchGroups[i].name + '" is empty. removing it!'); //Enable this line for testing only
		doc.swatchGroups[i].remove();
	} else {
		//$.writeln(doc.swatchGroups[i].name + ' group is not empty'); //Enable this line for testing only
	}
}

Script modified from: https://github.com/ExtendScript/wiki/wiki/ColorGroups