It’s not immediately obvious, but there are ways to match files in the manner you’re describing and capture information to perform actions on. Look at the section on Custom Attributes over on the Noodlesoft support pages.
If Hazel can’t hack it, you could always use A Better Finder Rename which offers two ways to automate:
If you have previously saved your settings into a preset, you can rename files by simply dragging them onto the closed application icon. A popup dialog will allow you to choose the preset to be applied.
Alternatively, you can store the settings into droplet mini-applications and perform a rename by dragging the files directly onto the droplet’s icon.
It seems like Hazel ought to be able to do this (I don’t have Hazel so I don’t have a direct answer), but this thread shows how you could do it using a folder action and AppleScript.