merge materials

Is there a script or easier way to combine duplicate materials in a scene than going in by hand and selecting the duplicates and assigning them to a single material? Maybe there’s something out there that combines any materials that have the same name?

Looking to keep my scenes tidy.

There’s one on scriptspot, removeDuplicateMaterials, I believe. It sometimes works.

“Instance material by name” by Alex Kramer, works perfectly.