How to set up physical materials for a large number of materials?

It’s unfortunate that that’s the only solution.
Given the scale of my material instances, it seems like creating a tool, testing it, and running it would take just as long as doing it all by manually.