Maybe leave a single-file version of this function instead, and just call it multiple times, once for each FileEntry that we get? I have a feeling, that it will greatly simplify the code, both here and in chooseEntries.

It's up to you though.