The technical answer is that you can file bankruptcy as often as you like, but you may not get the result you want, especially because of recent changes in the bankruptcy law.
A debtor cannot obtain a discharge in a Chapter 7 case if the debtor obtained a discharge in (a) a Chapter 7 case filed within the past 8 years, or (b) a Chapter 13 case filed within the past 6 years. The time periods in either case are measured from the commencement dates of the respective cases. The dates of discharge have no bearing on the disqualification.
In addition to these changes in how often a debtor can obtain a discharge in bankruptcy, Congress also enacted changes intended to reduce or eliminate the effect of the bankruptcy stay for serial filers. To oversimplify
the changes, the stay will last for just 30 days if a bankruptcy case of the debtor was pending within the preceding year but was dismissed. The stay will simply not come into existence at all if two or more cases were pending within the preceding year but were dismissed. If a Chapter 7 case is dismissed for abuse and the debtor files under a new chapter (such as Chapter 13), however, the stay has its normal duration.
Notwithstanding the above, you can be barred from filing a new case for 180 days after a case is dismissed, if the dismissal (a) is because you willfully failed to abide by an order of the court or to properly prosecute the case, or (b) was at your request after a creditor requested relief from the automatic stay.