Is it possible to group/join meshes by material?
Join all the mesh objects with Ctrl +  J (or type in Join after pressing  F3)

Then separate them by material with  P while in Edit Mode.

That should give you the result you seek.