Script to delete ALL items but 1 with groups

3.27K viewsScripting

Hello all,
Need help with scripting to delete all items in a category except 1. I have a script to delete all without any groupings but i can’t find anything that helps with grouped items.

I’ve attached a model that has Matrix1 with groupings and Matrix2 with no groupings. The scripts Action 1 and 2 below the two matrices.

Any help would be greatly appreciated.