Page 1 of 1

Rename file and remove recognized date in name

PostPosted: Thu Mar 19, 2020 4:55 am
by MrPlunder
Hello, everybody,

I have a little challenge changing the file name with Hazel.

In my rule I want Hazel to replace the date recognized in the filename with new defaults.

Here is the example
Original file:
20200317 filename.pfd or
2020_03_17_filename.pdf


Current change
2020-03-17 20200317 filename.pdf
2020-03-17 2020_03_17_filename.pdf

Desired change
2020-03-17 filename.pdf

Maybe someone here can help me.

Thanks a lot.

Re: Rename file and remove recognized date in name

PostPosted: Thu Mar 19, 2020 10:34 am
by Mr_Noodle
Look up "match patterns" in the help. Using those, you can use a custom date token to match the date part and a custom text attribute to match everything after that. You can then use those in the Rename action, re-formatting the custom date attribute to suit your tastes.

Re: Rename file and remove recognized date in name

PostPosted: Thu Mar 19, 2020 10:53 am
by MrPlunder
yes, that makes sense and works.

But I can't get it if a date is already in the filename and I just want to adjust it.

For example:

filename input: 2020-03-10 Noodlesoft.pdf move to
filename outgoing from Hazel: 2020_03_10 Noodlesoft.pdf

Current outgoing from Hazel:
2020_03_10 2020-03-10 Noodelsoft.pdf

current Outgoing setting:
1_date modified_1 2_name_2 3_extended_3
1_2020_03_10_1 2_2020-03-10 Noodelsoft_2 3_.pdf_3

Re: Rename file and remove recognized date in name

PostPosted: Fri Mar 20, 2020 10:44 am
by Mr_Noodle
If you use custom attributes to match the parts of the file, then in the Rename action, you use those custom attributes, and not date modified or name or any of the built-in attributes.