Renaming files with text from pdf

I’m using hazel to organize a bunch of training certifications I have for work so they’re easily accessible when I try to produce them. They all follow the same format and I want the file name to be ‘Name_Training_Date’. My issue is how do I extract the training name from the issues pdf. They’re all on the same line.

Any Automator workflows, AppleScript, or shell scripts needed would be of help or if there is something in hazel I’m missing.

Have you read/tried any of the examples in this thread?

Yeah you want to use this example from that thread @sylumer mentioned .

Matching and custom tokens are really, really powerful. sometimes they require some fiddling to get it to match properly. It can help to copy/paste text from one of the PDFs in case there are hidden characters or spaces that throw off your pattern matching.

I’ll try that shell script but the I guess I’m having trouble figuring out how to pattern match a line that can be a drastically different number or words.