Answered
How to ungroup all groups in a document?
Why this script doesn't end? The idea is to ungroup all the groups in the doc.
var doc = app.activeDocument;
var exit;
while (true) {
exit = true;
app.executeMenuCommand("selectall");
var sel = doc.selection;
for (var i = 0; i < sel.length; i++) {
var item = sel[i];
if (item.typename === "GroupItem") {
app.executeMenuCommand("ungroup");
alert('ungrouped!');
exit = false;
break;
}
}
while (doc.selection.length > 0) {
app.executeMenuCommand('deselectall');
app.redraw();
}
if (exit) break;
}
alert('exit while loop');