This is a matter of maintaining a simple static index mapping file names to their respective texture atlas. Usually it’s something you are doing already anyway when using texture packing.
I don’t understand this requirement. Surely you can modify the relative path as needed to allow for the texture lookup?