Wildcards in Filename, move to Wildcards in Folder

Hi!
Is there any possibility to do this:
In Folder "SCAN" are those files:
170318 This is some Filenametext 0253 0030.pdf
170315 This is someother Filenametext 0248 0041.pdf
Wildcard should detect 0253 0030 in the one and 0248 0041 in the other filename.
And move each to a folder that looks like:
****M Somefoldertext/
eg:
0253M Thisistheactualfoldertext/
and
0248M Thisistheotheractualfoldertext/
If the folder does not exist, do not move that file.
I am sure it works, but i am sure that i can't do it without your help.
Is there any possibility to do this:
In Folder "SCAN" are those files:
170318 This is some Filenametext 0253 0030.pdf
170315 This is someother Filenametext 0248 0041.pdf
Wildcard should detect 0253 0030 in the one and 0248 0041 in the other filename.
And move each to a folder that looks like:
****M Somefoldertext/
eg:
0253M Thisistheactualfoldertext/
and
0248M Thisistheotheractualfoldertext/
If the folder does not exist, do not move that file.
I am sure it works, but i am sure that i can't do it without your help.