Alpakka has a file rotator, but this will only be optimal for you, if the elements not really alternate (bcs it meant to rotate files completely, and not keeping the substreams (and files) open).
If the files you need to write to are alternating (like a.txt, b.txt, a.txt, b.txt), I think you should modify the LogRotatorSink to keep N substreams open, sorted by the last usage.