Face Selection Based on Material Name

I have a CAD model that came into 3ds Max with multiple copies of a base group of materials. In a group of about 50 base materials , each of those 50 materials has anywhere from 2 -50 copies in the scene, resulting in hundreds of individual materials that are being fed into their own slot within a handful of multi/sub materials. I am trying to consolidate these materials so that I instead of 20 identical “brass” materials I have only one “brass” that is assigned to a single material ID within a master multi/sub material for the scene.

I found a script that can consolidate materials based on the material name. For example it will have you select a single “brass” material and it will then replace any material that has the same name with an instance of the material you selected. While this is helpful in reducing the overall material count it still leaves me with the same breakdown as far as material IDs. I may have reduced 10 materials to 1 but in my multi/sub material I still have 10 slots that contain a “brass” material. The attached image shows the end result. Ideally it would be nice to:

1) Identify a group of materials that share the same name
2) pick a single material from that group to be your base material
3) replace the other materials with an instance of your base material
4) collect a list of the mat IDs from the materials being replaced
4) Select any faces connected to those mat ID’s
5) Assign them with a new ID designated by the user

I can get through 1-3 with the script that I have but it would be great to find a solution to the rest of it.
Instance Mat by Name and Class: http://3d-kstudio.com/trackscripts/

AttachmentSize
consolidated_sub-materials.jpg419.74 KB