Hazel won't give the correct date on a certain credit card statement?

I use Hazel to re-name and manage all of my banking statements in the format of

[statement date] - [credit card name] statement.pdf

I recently opened the Amazon credit card and got my first statement and I can’t write a rule to get the correct statement date. The statement date appears second on the document, so I try to format the rule as “contents - contain match - 2nd date”. Except it just renames it with today’s date. If I try the first and 3rd dates, it captures it and names the file with that date like it should.

But the date it needs to be is the 2nd, and I don’t know why it’s not working.

You can see what Hazel sees by clicking on the red x or green tick in preview mode. It is very helpful in these situations.

On my Amazon statement I’m grabbing it as the first date in the following manner and then using it to rename and file the PDF.

My statement looks like this:

and my Hazel rule looks like this:

I have the Synchrony Amazon card and it looks a little different. I have rules for it set up almost identical to yours, but the date I need is the second occurrence. But it won’t grab the second for some reason. It will grab the 1st, 3rd, 4th, etc but not the second. :thinking:

I’ve had similar problems and nothing seems to work all the time but occasionally I can get it running by counting from the bottom instead, as in X from the end statements in Hazel

I gave this a try and it still doesn’t work. For some reason, it can find every date except that one. I’m to the point where I could just manually name this one document every month, but I really want this automated. :sob:

Gave this a try. It doesn’t match any dates when I select “2nd occurrence”. And only on my Amazon credit card statement. If I select 1st and 3rd occurrences for troubleshooting purposes, it will match the date and show me in the preview.

I’m guessing Hazel has an error catching system to just use today’s date if it doesn’t match a date? But I still can’t figure out why it can’t find the second date. I thought maybe the document was OCR’d correctly, but I can do a text search for the date and it will find it.

Maybe I can try reaching out to the developer.

Another thing you can try, which is what I used to do before the preview feature. You can open the PDF and select the whole thing, copy and paste it into a text editor. You will then also see what hazel sees. Are you using a “digital” PDF from your bank or are you scanning a paper statement? If digital perhaps the second date is, for some strange reason, a graphic? I haven’t seen that but it could explain it.

The joys of text recognition in PDFs. My go-to solution for this is to CMD-A the contents of a PDF, and then paste into a text editor. You’ll get a lot of text, most of which doesn’t make sense, but you should be able to see the dates that you’re trying to parse. And Hazel, I believe, respects the order of this copy-pasted text.

It’s a downloaded copy from the account portal.

So I tried that. Looks like the date I need is the first date in the text. So I went back and set Hazel up for first occurrence. Still not picking it up. It’s picking up what I thought was the first date (but appears second in the text) as the first item even though the statement date appears first in the text. Second item sets it to the current day even if done on different days.

Every other date matches correctly. The date is formatted like a normal date, so Hazel’s regular expression matching for dates should pick it up.

I’ll reach out to the developer in the morning for ideas of troubleshooting as well and post here if I can get it working.

He is very responsive and I have had a lot of success posting in the forums where he is very active. https://www.noodlesoft.com/forums/viewforum.php?f=4&sid=5fac6c08792c68128b64342c54ed7984

Try using a Custom Text match. Even better if there are regular characters preceding or succeeding the date you want include them as well, then use the Replace Text function to remove the additional characters when renaming the file.

1 Like

I was able to get it working with this. I don’t know why the date matching in Hazel can’t find this date. I’m assuming Hazel uses regular expressions to match dates, so I have no idea.

Thanks for the idea!

1 Like

Thanks, this is an awesome tip. I did this, and it saved me a lot of time! Thanks @andrew.j.pfeiffer