Page 1 of 1

"capture" a date in a text pattern and rename like YYYYMMDD

PostPosted: Wed Mar 08, 2023 7:35 am
by bellamerighi
Hi, I'm used to download some bank documents once or twice a year. They have not the right date contained in the metadata cause they are generated by the system as i download them: the reference date is in the filename.

I'd like to catch the date contained in the filename and convert it in the YYYYMMDD format.

filename ex LQ06-LQ_ E_C SCALARI / 28_02_2021 .pdf

Can Hazel get the date in the filename and then rename the file for ex 20220401_everything.pdf?

My rule catch the date correctly in the filename but I can't figure how to instruct hazel to perform the rename, cause Hazel catch it yes but like a text pattern not a date.

thank you

-m

Re: "capture" a date in a text pattern and rename like YYYYM

PostPosted: Wed Mar 08, 2023 10:31 am
by Mr_Noodle
Look up match patterns in the help. You can use a custom date attribute to do what you want.

Re: "capture" a date in a text pattern and rename like YYYYM

PostPosted: Wed Mar 08, 2023 1:02 pm
by bellamerighi
Yes, I did it in conjunction with hazel's live preview: name matches (…)(day_month_year)(…) and it's ok, Rule matches.

So I have matched the date in the filename. Now, the question is how have I to set up hazel to rename the file with the date in format YYYYMMDD?

thank you.

-m

Re: "capture" a date in a text pattern and rename like YYYYM

PostPosted: Thu Mar 09, 2023 10:27 am
by Mr_Noodle
If you created a custom date token, then in the Rename pattern, look at the list of attributes available. The custom date attribute should be there. Drag that into your pattern, then click on it. There will be an option to edit its format.

Re: "capture" a date in a text pattern and rename like YYYYM

PostPosted: Thu Mar 09, 2023 12:02 pm
by bellamerighi
OMG it works! In the Rename field I've used my custom data token, then "Edit Date Pattern" and rearranged them in the yyyy_mm_dd format.

solved.

thank you

-m