face intersection ... function/script for automatic repair?

Hi all,
i am looking for a way to automatically repair the following errors in my stl-imported meshes:

The meshes have certain areas in which some faces intersect - i need the mesh to have a closed surface for stl-export. Is there a way/function/script that remeshes that area to eliminate face/edge intersections? Repairing the meshes by hand is not a solution since i will need to repair many meshes and hopefully will be able to write a script for everything that has to be done in the end. thank you for any help!