partial matches of name and existing subfolder?

Is there some native way of matching a file where only a partial is the same as a string in an existing subfolder that the file is sorted into, instead of Hazel creating a new one?
I have an existing subfolder structure with hundreds of folders of unique serial numbers. In the parent folder an external process is adding files and the file names also contain the same serial numbers. What I need is to match up the file with serial number as xxxxx: "Lots-of-variable-text(xxxxx)" with an existing folder: "Project-xxxxx-Lots-of--other-variable-text". Seems like something very typical to be able to do.
I'm thinking there might be a simple way to at least get the serial out of the file and folder names — which are partial strings — and match them with applescript, but maybe there's even an existing native way to do partial matches?
I have an existing subfolder structure with hundreds of folders of unique serial numbers. In the parent folder an external process is adding files and the file names also contain the same serial numbers. What I need is to match up the file with serial number as xxxxx: "Lots-of-variable-text(xxxxx)" with an existing folder: "Project-xxxxx-Lots-of--other-variable-text". Seems like something very typical to be able to do.
I'm thinking there might be a simple way to at least get the serial out of the file and folder names — which are partial strings — and match them with applescript, but maybe there's even an existing native way to do partial matches?