If the foreclosure takes place, someone will knock on your door and/or leave a notice on your door with your options. Heather mentioned cash for keys. That will be one option. As a tenant, you also have rights. Another option will likely be to stay and pay rent to the bank, however you will have to agree to cooperate with real estate showings when they put the property on the market. If the listing agent reports to the bank that you are not cooperating with agents and making appointments, you will be evicted. If you don't want to be bothered with showings, I suggest you negotiate cash for keys, and take the money.
Do keep in mind that just because a foreclosure sale is scheduled for August 24th, it doesn't mean it is definitely going to sale! These sales get cancelled (or adjourned) all the time, sometimes several times before they actually happen. You can usually find the foreclosure sales on your county sheriff's website or somewhere online to see if it went through.