I can do such a script in Python. You will be able to add it to your GIMP instance and run it from Image->Delete Layers! (this can be changed if you want that). Currently i have a working prototype that allows me to delete every layer that is named like my input and i can easily change that to obtain the behavior that you requested.