Deleting from a file name

Could someone please help me bumble my way through this.
I want a macro to remove the first 13 characters of a file name (this is the date in this format 'yyyy-mm-dd - ')
I'm lost right from the start but assume it's not too difficult to achieve.

Many thanks


You are right - it isn’t difficult once we know where you are starting from.

Is the file you want to rename selected in Finder? Or please explain your workflow.



Yes, I have some files automatically named with the date first, occasionally I want to manually move some in the Finder but remove the date at the same time. presently I am doing it manually.

So I would select the file in the Finder and invoke the macro to remove the date.

Thanks for your time.


This will do what you've asked. Before you use it in anger, try it out on some files that are not important, just in case things go wrong. I have tested it here and it seems to work, but it might do things differently to what you are expecting. Note - you'll need to set a trigger for the macro; just decide what you want and specify it where it is highlighted in red.

Select the files you want to rename in Finder and then run the macro. Any files that don't contain the date string that you specified will be left untouched.

Rename Files.kmmacros (3.1 KB)


Thank you. Looking at your macro I think I understand what is happening though I would never have got there myself. I was expecting just to delete a fixed number of characters from the file name but your suggestion is much better in matching the pattern.
I will use this and also try to adapt it for other uses. Many thanks for your input, it is much appreciated.

You're welcome - stay safe!