PDF renaming - can't get custom token to pull info correctly

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I'll start by apologizing for even asking. I've searched and seen various themes about this process discussed and read all the manual areas about match patterns, and googled, and youtube'd, etc and still can't get it to work. I'm missing the obvious apparently.

I'm trying to rename a PDF based on the name of the person contained within and some date info. I can get it all to work other than the person's name and I think the issue is that when hazel is processing the PDF (which is NOT an OCR'd pdf, but a generated PDF file). When I use the preview function, it has ALL of the words in the PDF listed so I know it sees them, but I can't get Hazel to pull the info I want.

Here is what the data field looks like in the preview window of Hazel:

===========================
Pilot Certificate) issued.
MEDICAL CERTIFICATE THIRD
CLASS
AND STUDENT PILOT CERTIFICATE
3. Last Name First Name Middle Name
JOHNSON
FRED
Robert
4. Social Security Number
============================

I'm wanting to use the names below "3. Last Name First Name MIddle Name" in the new filename of the PDF. But when I do the custom token, I get an error when trying to parse out the name. I'm trying to anchor the custom token to grab the words following "3. Last Name First Name Middle Name" but I'm unsuccessful and thinking that is because it's on a separate line. Because of that, I tried using the custom table function but still can't get it to pull that out.

Can anyone help be navigate this. It should be so easy and I am apparently making it SO HARD.
tbobpage
 
Posts: 3
Joined: Mon Jun 15, 2026 10:33 am

What exact error are you seeing? Can you post screenshots of your pattern? Use imgur.com if you don't already have your own cloud file sharing service.
Mr_Noodle
Site Admin
 
Posts: 12224
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

definitely can - give me a bit because I'm using confidential information and have to remove it or change the words (like the name listed in my post). I wish I could just show the whole PDF and how it's showing in the preview. If I redact some info and post that maybe that will help too.
tbobpage
 
Posts: 3
Joined: Mon Jun 15, 2026 10:33 am

https://imgur.com/a/3S9Yt3h

First image is what the "'preview" is showing me in Hazel (when I click the green arrow [or red X if applicable]). I'm trying to pull the name which is listed one line below "applicant name" (there are a few other areas on the PDF where there is the name but this seems to be the easiest one to specifically reference in the rule). The name has usually the first, middle, and last name but sometimes just the first and last.

Ultimately I am trying to pull the name out of the PDF and use it in the name of the PDF file along with the date and some other info, all of which I can get working just fine. I'm just struggling with understanding how to get Hazel to recognize the location of the data I want to pull off of the PDF and use for the PDF title renaming. I've been digging for several days and at this point I'm obviously overthinking it and just can't solve it without some help so please accept my deepest thanks for explaining this like I'm five. lol.
tbobpage
 
Posts: 3
Joined: Mon Jun 15, 2026 10:33 am


Return to Support