find maching file names in subfolder

I have several files and folders in my download folder.
I'm looking for an action, which looks at matching content name of the several folders in the download folder,
if there are already files in the folder with matching names, the files in the download folder will be sorted into the same place of the other matching file name.
Downloads
ABC.txt
DEF.txt
folder-XY
-ABC.jpg (inside folder-XY)
folder-ZX
-DEF.jpg (inside folder-ZX)
ABC.txt should be placed into the folder-XY
and DEF should be placed into the folder-ZX
Hope somebody have a solution for me.
I'm looking for an action, which looks at matching content name of the several folders in the download folder,
if there are already files in the folder with matching names, the files in the download folder will be sorted into the same place of the other matching file name.
Downloads
ABC.txt
DEF.txt
folder-XY
-ABC.jpg (inside folder-XY)
folder-ZX
-DEF.jpg (inside folder-ZX)
ABC.txt should be placed into the folder-XY
and DEF should be placed into the folder-ZX
Hope somebody have a solution for me.