Page 1 of 1

Adjust the date to first day of the next month?

PostPosted: Fri Feb 07, 2025 4:03 pm
by morganadam
Is there a way to have Hazel find a date in a pdf file and then automatically adjust it to the first day of the next month?

The reason: One of my favorite uses of Hazel is to identify monthly bills in my downloads folder, move them to a 'bills' folder and then rename the file and sort them into subfolders by year and bill type. Unfortunately, with new accounts (and ever-changing pdf layouts from existing accounts) the place I spend the most time on is having Hazel identify the correct date I want. Sometimes there is the letter date, the billing date, the coverage dates, etc. After trial and error I am usually able to get it by finding a unique way the specific date I want is presented... but not always.

As an example: I have a new health insurance company and I would like the bill to be sorted by the first day of the month of coverage (not the billing date). For some reason due to the layout I cannot isolate this for Hazel. But what would be easy is to grab the first date of the pdf. This will always be within the month prior to what I wish to name the file. So if Hazel could find the first date within the email ("Feb 5, 2025") and automatically change it ("Mar 1, 2025") then I can have the file renamed to '2025-03-01 - Health Insurance' and sorted accordingly.

Thanks!

Re: Adjust the date to first day of the next month?

PostPosted: Sat Feb 08, 2025 6:44 pm
by morganadam
So I came up with my own solution if this helps anyone else. I had Hazel auto detect the first date found. Then I had it adjust the date by adding 1 to the month. Then for the file name I used the date format to rename the file with only year and month (ex. "2025-03") and then append the day by text ("-01").

Still curious if there was a more direct way I'm missing...

Re: Adjust the date to first day of the next month?

PostPosted: Mon Feb 10, 2025 11:28 am
by Mr_Noodle
Nope, that sounds about right.