Pull first line of OCR with Hazel?

Hi All,
I don’t know if this is possible or not, but it would be really convenient if I could pull the first line of OCR’ed text from a document and use Hazel to rename the document that. It would make it faster for me to rename music (where the title and instrument are the majority of the readable text) or for documents that Hazel doesn’t automatically know where to put.

Does anyone know if this is possible/how to do this?

Thanks!

So your script needs to find the first new line and capture everything before it - assuming lines are delineated by new lines.

The bigger issue might be cleaning up that first line to become a legitimate filename.

maybe grep it with regex? (until the full stop, or line break?)