Hi @JosethSC,
Take a look at the tail end of this thread:
The basic idea is to loop through the sprite layers in a recursive function, counting layers except those in categories you don’t want (for example reference layers or the background layer). If the current layer is a group, then the recursive function calls itself, supplying the layer’s children.
Then create the layer and assign its name. For extra number formatting, look into Lua’s documentation on string.format
.