Uploading file to OpenAI for processing: How do I get the AI to map the files and results (correctly and consistently)?

I want to upload 10-100 files and tell GPT4-Turbo to evaluate them based on some criteria, compare them and rank them according to some scores, then return the results to me. I told the AI to map the file id to the matching result.

But I can’t get this working consistently: some of the results has incorrect file id.

Is there a good way to make GPT4 correctly map files to outputs?
Should I reconsider my approach? I can evaluate the files one by one, but then I can’t tell the AI to compare them and rank them (which is a hard requirement).