Page 1 of 1

convert month-name into month-number

PostPosted: Mon Oct 31, 2022 10:35 am
by rocky7692
I have a monthly PDF that contains the sentence "... September 2022".
How can I teach Hazel to make "09" out of "Septemper" which I can then use when renaming the PDF?
Every month only the month name changes before the year 2022.
So each month name should be converted to the number of the month.

I hope I was able to express myself clearly.

Thanks for your help in advance.

Re: convert month-name into month-number

PostPosted: Tue Nov 01, 2022 9:45 am
by Mr_Noodle
Look up "match patterns" in the manual. You can set up a custom date attribute to capture the date in the file. In the Rename pattern, you can use that date attribute. After dropping it into your pattern, click on it to reveal more options. One is to edit the format. There you can set it to display the month as a number.

Re: convert month-name into month-number

PostPosted: Wed Nov 02, 2022 2:24 pm
by rocky7692
Mr_Noodle wrote:Look up "match patterns" in the manual. You can set up a custom date attribute to capture the date in the file. In the Rename pattern, you can use that date attribute. After dropping it into your pattern, click on it to reveal more options. One is to edit the format. There you can set it to display the month as a number.


Thanks for that. I think I've been able to do that so far.
But how can I display the month-number with two digits when renaming?
Hazel is currently "translating" September for me as 9, but I need 09 in this case.
So anything less than 10 with a leading zero.

And will Hazel understand german month names "Januar", "Februar", "März" etc. correctly?

Re: convert month-name into month-number

PostPosted: Thu Nov 03, 2022 10:04 am
by Mr_Noodle
When editing the date format, click on the month item. There should be options, including one that has both digits underlined. That option specifies that the month is always two digits (so there will be a leading 0 for single digit months).

Re: convert month-name into month-number

PostPosted: Thu Nov 03, 2022 2:44 pm
by rocky7692
Thank you Mr_Noodle that works great and german month-name are recognized correctly. Perfect!