Changing date format and position in a file name

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

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!
Bruxced
 
Posts: 3
Joined: Tue Jun 26, 2007 5:59 pm

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.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

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 :-)
Bruxced
 
Posts: 3
Joined: Tue Jun 26, 2007 5:59 pm


Return to Support

cron