list manipulation – select partially matching filenames

First, join the two groups:

Join(files1, files2)

Then gather them by their last 3 numbers like:

StringCases("DT120_blur7_Defoc=050um_AstigX=000um_AstigY=260um.png", DigitCharacter ..)

(*Out: {"120", "7", "050", "000", "260"} *)


StringCases("DT120_blur7_Defoc=050um_AstigX=000um_AstigY=260um.png", DigitCharacter ..)((-3;;))

(*Out: {"050", "000", "260"} *)


GatherBy(Join(files1, files2), StringCases(#, DigitCharacter ..)((-3 ;;)) &)

Then select groups that have two elements:

Select(GatherBy(Join(files1, files2), StringCases(#, DigitCharacter ..)((-3 ;;)) &), Length(#) == 2 &)

(*Out: {{"DTideal_circ_def=000um_astX=000um_astY=410um.png", 
         "DT120_blur7_Defoc=000um_AstigX=000um_AstigY=410um.png"}, 
        {"DTideal_circ_def=050um_defX=000um_defY=010um.png", 
         "DT120_blur7_Defoc=050um_AstigX=000um_AstigY=010um.png"}} *)