Page 1 of 1

Noob trying to rename PDFs based on contents in the PDF

PostPosted: Thu Jan 02, 2025 8:30 pm
by all1word
Hi. I've been beating my head against the screen, trying to figure this out. I've even used ChatGPT Hazel helper to try and accomplish it. Specifically, I want Hazel to:

Extract the Merchant, Date, and Amount from the text inside the PDF.
Rename the files using this pattern: [Merchant] - [Date] - [Amount].pdf.
Here’s what I’ve done so far.

The PDFs are from my Chase bank. They all have a line for Merchant, Date, Amount.

I jsut can't figure out how to do the custom tokens. I'm sorry if this has been answered elsewhere (I'm sure it has). I've looked at other questions / use cases and frankly, I just don't understand it enough. I'm hoping if I can do it here with this specific case, I'll be able to figure it out.

This is what the ChatGPT Hazel Helper suggested I do:

Set Up Rules:
In the conditions, I’m using Contents contain match with the following regular expressions:
For Merchant: Merchant (?P<Merchant>.+)
For Date: Date (?P<Date>\w+ \d{1,2}, \d{4})
For Amount: Amount \$(\d{1,3}(?:,\d{3})*(?:\.\d{2})?).

The tokens (blue bubbles) are not being created, even though I’ve typed the regex patterns in the "Contents contain match" field.
Without these tokens, I can’t use them in the rename action, and my files end up named literally as [Merchant] - [Date] - [Amount].pdf.

I know it shouldn't this hard, I just don't know how to do it. lol. thx in advance.

This is what I get from PDF when I copy and paste it from the PDF.

Chase Logo
You made an online, phone, or
mail transaction
Account Ink Business Preferred (...5795)
Date Dec 5, 2024 at 12:08 AM ET
Merchant PP*APPLE.COM/BILL
Amount $0.39

Re: Noob trying to rename PDFs based on contents in the PDF

PostPosted: Fri Jan 03, 2025 9:27 am
by Mr_Noodle
ChatGPT is wrong here. You do not type in regexes. You need to drag/click on the tokens to add them. Please read the manual on match patterns, and not rely on things like ChatGPT.

Re: Noob trying to rename PDFs based on contents in the PDF

PostPosted: Fri Jan 03, 2025 11:06 am
by all1word
Thanks Mr. Noodle. I tried reading the forums and the FAQ before I went to our digital overlords. I couldn't quite get it frankly.

Would you mind telling me or demonstrating (for the thousandth time I'm sure) what I would do to capture everything after a word like, Amount, please? I know that I want to turn that into a token, but I have a brain lock I guess where I can't quite picket up from the literature.

Thx again and apologies for my ignorance.

Re: Noob trying to rename PDFs based on contents in the PDF

PostPosted: Mon Jan 06, 2025 10:40 am
by Mr_Noodle
Let's say, for merchant, it's the word "merchant:" followed by some text then the end of the line. You can use a pattern like:
Code: Select all
    Merchant: (• merchant)

(• merchant) is a custom text attribute. It's pattern would be "anything" if you want to match any text (up to the end of the line). You can use more specific patterns as needed.