How to find out how much it costs the bank to foreclosure?

Is there a way to find out or is there a percentage of finding out how much it would cost the bank to foreclosure on a house?

NO.

But, the industry average is $30,000 - $40,000.

Depends on the state and type of foreclosure (judicial or non-judicial). Here in CA a non-judicial foreclosure, where a deed of trust was used to secure the loan, it can be done for about $1500. I don’t know how much a judicial foreclosure costs.

Yes, buts that not the actual real cost for the company. Its much larger than that. There are many other factors involved.