As far as I understand it, the SetDatablockOptimize instruction will optimize the installer and not include duplicate files.
This command tells the compiler whether or not to do datablock optimizations. Datablock optimizations have the compiler check to see if any data being added to the data block is already in the data block, and if so, it is simply referenced as opposed to added (can save a little bit of size). It is highly recommended to leave this option on.
Apart from that, you could always use functions that extract the files and change the output path before calling those functions.
Section
SetOutPath "first_path"
Call ExtractBaseFiles
SetOutPath "second_path"
Call ExtractBaseFiles
SectionEnd
Function ExtractBaseFiles
File "first_file"
File "second_file"
FunctionEnd