Automate tasks on editor

When I open Unreal Engine I get several messages of mesh actors with null mesh property. I want to delete all these actors. I don’t want to delete them all one by one because it’s tedious. Is there a way of writing scripts that run on the editor and operate on the scene being edited so I can do something that conceptually looks like this?

for object in scene
    if object is StaticMeshActor and object.mesh == nullptr
        destroy object

The idea is that the script modifies the actual .umap file, not that it modifies the scene in game once the game is running.