How to remove all unused material slots of all objects?

Hello,

i have over 50 objects and I have a lot of unused materials in the materials slot. So purge all the materials wont remove the unused slots. How can I remove all of them of each object as once?

You can try this

or this