I created a Photoshop Script for something similiar.
I had a project with 10+ renders, each having 12+ object buffers to be used as Photoshop masks. Because all my MultiPasses were neatly labeled, I didn't want to copy-paste the contents from each layer into a channel and do the same for each label 120 times.
This Photoshop script converts all the PSD layers to channels, with the option to skip hidden layers, skip the Background layer (BeautiPass), and delete all converted layers.
https://thriving-cobbler-829fa7.netlify.app/layers-to-channels.jsxCheers.