Page 1 of 1

How to use extracted date attributes in Hazel scripts

PostPosted: Thu Aug 21, 2025 7:19 am
by grgsiocl
Most of my PDFs (like bank statements or invoices) only contain a statement date. To file them correctly, I need Hazel to calculate the financial year (April–March in India). For example:

• 30-Mar-2025 → FY 2024–2025
• 14-Apr-2025 → FY 2025–2026

I can already extract the invoice/statement date from the file using Hazel’s “Contents” match and save it as a custom attribute (e.g. invoiceDate). The problem is: when Hazel runs a script or Shell Script, it only passes $1 (the file path). I don’t see any way to pass invoiceDate (or any other attribute) into the script.

Basically, I want Hazel to pick up the invoice date, figure out the financial year, and then move the file into the correct folder automatically. I can handle the script logic for FY calculation, but I’m stuck on how to get Hazel’s extracted attribute into that script. Is there any alternative solution?

Re: How to use extracted date attributes in Hazel scripts

PostPosted: Thu Aug 21, 2025 8:43 am
by Mr_Noodle
Instead of a script, how about using the date adjustment function. You can subtract 3 months from the date and then use the resulting year.

Re: How to use extracted date attributes in Hazel scripts

PostPosted: Thu Aug 21, 2025 9:19 am
by grgsiocl
Mr_Noodle wrote:Instead of a script, how about using the date adjustment function. You can subtract 3 months from the date and then use the resulting year.


Thanks, noodle, for the idea. Based on your suggestion, I did the following: I sorted the files into subfolders with a pattern: "Date (Subtracted by 3 months) - Date (Adjusted with 1 year and subtracted by 3 months)." I tested it on a file, and it worked fine. I just want to know if I understood your logic correctly or if there are any adjustments that need to be made.

Re: How to use extracted date attributes in Hazel scripts

PostPosted: Fri Aug 22, 2025 8:28 am
by Mr_Noodle
No, that should be it.