Page 1 of 1

Changing date format and position in a file name

PostPosted: Sun Jul 17, 2022 3:26 am
by Bruxced
Hi,

After a few years trying multiple things for naming files, I have decided to settle for the format YYYY-MM-DD or YYYY-MM when the filename must contain a date (for example invoice). Now I would like to rename some old files and have two questions:

1/ Is there an easy way to change file names which would contain "YYYYMMDD" or "YYYY MM DD" to "YYYY-MM-DD"?

2/ Is there an easy way to move the date string from the beginning of the filename to the end or vice-versa?

For example:
"202207-Telecom-Invoice.pdf" would become "Telecom-Invoice-2022-07.pdf"

Thanks a lot for your ideas!

Re: Changing date format and position in a file name

PostPosted: Mon Jul 18, 2022 9:46 am
by Mr_Noodle
You can set up a match pattern to detect that format. Use a custom date attribute to snag the date and a custom text attribute to grab the rest of the file name. You can then rename, re-ordering and reformatting those attributes as you see fit.

Re: Changing date format and position in a file name

PostPosted: Mon Jul 18, 2022 11:43 am
by Bruxced
Mr_Noodle wrote:You can set up a match pattern to detect that format. Use a custom date attribute to snag the date and a custom text attribute to grab the rest of the file name. You can then rename, re-ordering and reformatting those attributes as you see fit.


Thanks Mr Noodle! I hadn't thought of using a text attribute for the rest of the file name! Duh ;-) Will quickly try that. Hazel is so powerful :-)