Flag Animation looping (for a game)

I need to make a wind-flapping-flag animation that would lasts for 7-10 frames, loop it, bake it and export it to ASC frame by frame. How do I do that?
Thank you.