Delete unused templates

We are on ES version 6.8.0. Due to an issue in our software, we ended up having 30k unused templates on a 3 node cluster. Deleting these one by one is really slow like each one is taking upto 2 minutes and some are timing out after 2 minutes. Any easy way to delete these unused templates? I tried a wild card delete and that doesn't seem to work and timeout as well.

Thanks in advance

Oh wow, that's pretty huge. It's likely timing out due to cluster state updates being slow, but I don't know of an easy fix here.

Someone else will hopefully pop in with some better advice!

Thanks Mark. I am hoping, there is some workaround out there. If not, I may have to look at spinning a new cluster and moving to that instead.

Safe to assume you adjusted the timeout parameters on the request to be longer?
I don't have anything good to add here, but based on what Mark said, and the fact that you have a small cluster, perhaps you can reduce the shards/replicas, shrink your cluster to a single node, then run it... maybe that would speed it up?