Help With a simple Mac Automator workflow

I have a camera that takes RGB and thermal images at the same time and I am trying to automate the process of sorting and separating the files. The two images are the same format (JPEG: *.jpg) but come with an underscore and letter to differentiate them, such as:
example_T.jpg
or
example_W.jpg

I have had no luck getting Automator to sort or filter according to the content of the name. Any help appreciated. Thanks.

I don’t have an answer for using Automator, but it sounds like something Hazel would be perfect for.