Hazel help - Renaming based on date in pdf

Hi all,

So I’m trying to retroactively sort and rename my payslips. The new ones are fairly simple, I have IFTTT save all attachments to a folder in Dropbox, and Hazel acts on the folder to sort them, renaming based on the date the pdf was created.

However, it’s easy enough to go into my mail and drag out all of my old payslips into that same dropbox folder, but it only renames it based on the date created, rather than the date of the payslip.

I’ve managed to OCR the payslip and create a variable that looks for “Pay Date: ##.##.####” and then renames the file based on this. Unfortunately this replaces the : with / due to file name conventions, and the date is not in a great order for sorting (would prefer YYYY-MM-DD. I’d love to be able to extract out the date alone, re-order it, and the use it to rename the file. Any ideas?

Hazel will let you reorder the date into YYYY-MM-DD for file renaming purposes. Just click on the little downward pointing chevron on the right side of the Custom Date element in the rename action.


Hi Chris,

Thanks for replying. Unfortunately this doesn’t work, as Hazel doesn’t know that it is a date. It’s finding “Pay Date: ##.##.####” in the document, removing "Pay Date: " and replacing it with nothing. I’ve since had it remove all of the periods to replace with dashes. So what it’s left with is DD-MM-YYYY, but Hazel isn’t aware that it is a date. Does this make sense?


If you want Hazel to be able to treat it as a date, you’ll need to use the Custom Date element in your “contain match” rule.

1 Like

Thank you Chris! I was using CustomText instead of CustomDate. This is actually perfect.

Was looking to rename some pay slips today and this post helped me get the answer. Thanks for that!