ISO script that compiles the identical sublayers of each group into their own sprite sheets

So, for my Aseprite file workflow, I have a group for each character animation. Each group has the same number of layers, and those layers all have the same names across each group.

E.g. The Side animation group has layers (Hair, Body, Eyes, Shirt, …)
The Front and Down animation groups have layers (Hair, Shirt, Body, Eyes, …)

and all groups/animations exist within the same .aseprite file.

I am trying to figure out how to write a script that takes each layer of the same name, across all groups, and compiles them into one vertical sprite sheet. So my output would be a series of sprite sheets (Hair.png, Shirt.png, Body.png, …) that combine the frames of that layer from each group.

I have seen similar scripts that flatten the groups and compile them into sprite sheets, but this can only be done with one layer visible at a time to achieve what I want-- and hiding/showing each manually ends up being very time consuming as the number of groups and layers increases.

Does anyone know of any scripts out there that can achieve exactly what I’m looking for? If not, how would I be able to get this working?

Thanks in advance!