Change Sequence in File Name (macOS)


This is a workflow puzzle.

For years I have used David Spark’s dating system for my PDF and other files. Unlike David, I used the sequence YYYYMMDD without dashes. It has served me well and I am indebted to him for making my files orderly for many years since his Paperless ebook (now updated to online tutorials - utterly brilliant).

One of the consequences of Covid-19 on my job is providing e-bundles of documents with tabs and linked indices rather than paper bundles. I have adopted software so that I can put in my PDFs, arrange them around to comply and the software generates an index for each bundle as well as the documents in proper order. The problem is that YYYYMMDD does not look good - even with dashes. I have had to adopt DD-MM-YY to comply with how these bundles have to be presented and to avoid manually dating each document.

Does anyone know how to batch rename files to convert the string YYYYMMDD to DD-MM-YY? I have Keyboard Maestro 9.1 and I have A Better Finder Rename 11. I am able to use AppleScript on a ‘cut and paste with minimal edits’ basis!

Thanks for your help!

If all the files are named with YYYYMMDD at the front of the file name, back up first and try this in A Better Finder Rename:

Screen Shot 2020-12-29 at 11.30.58 AM

Pattern: (\d{2})(\d{2})(\d{2})(\d{2})
With: $4-$3-$2

This works for me in A Better Finder Rename 9.


evanfuchs beat me to it.

It looks like A Better Finder Rename and Keyboard Maestro support regular expressions. Here is the substitution regex you need.


s/A/B/ means substitute B wherever you find A.
\d means any digit, {2} means 2 of the previous character, so \d{2} means any 2 digits.
(A) means capture A for later use. so (\d{2}) means find 2 digits and capture them for reuse. To get only the last two digits of the year, we first match the first 2 digits of the year but don’t capture them. Then we find the last two digits of the year and capture them for reuse like this \d{2}(\d{2}) We then capture the month and day digits with the same technique.

That takes care of everything in the pattern up to s/\d{2}(\d{2})(\d{2})(\d{2})/ The part after the second slash is where we reuse the patterns we captured. \1 means the first pattern that was captured. \3 means the third one that was captured. Since we capture year as 1, month as 2, and day as 3, we use \3-\2-\1 to print out DD-MM-YY.

Then we write the last slash to indicate the end of the regular expression string to get what we started with


Bonus points for the solid explanation! Well done @jahala


Now THAT is a Mac Power User!

Just for fun…

Screen Shot 2020-12-30 at 02.06.01 AM

DEVONthink 3’s Tools > Batch Process

Screen Shot 2020-12-30 at 02.06.32 AM

1 Like


That is beyond fantastic! Thank you so much evanfuchs for the ABFR formula, which works like a dream, and jahala for the explanation, which makes me understand the formula.

A big thank you to both - you have saved me hours of time.

Woah. I’m impressed!

YYYY-MM-DD looks good to me :slight_smile: - I appreciate the way that it reads and sorts. MM-DD-YY does not sort properly and to me is another reminder that I moved to a primitive country that crashed a Mars probe because it still uses imperial units. (And no, let’s not call them “English units” because apart from miles on roads, England doesn’t use them any more and neither does the rest of the United Kingdom.)

1 Like

With no intent to detract from your goal to comply with others’ requirements …

“Looks good” is subjective. Standards change over time. After using various versions of YYYYMMDD for a few years, for me this format is comfortable and “looks good”. My favorite variant of this is YYYY_MM_DD.

Other formats (DD-MM-YY) look dated to me and make no sense. Using this would be like continuing to use an old character font such as Courier. Or like the British continuing to use pounds, guinea, shilling, and quid. As @Diane stated above, there are problems the DD-MM-YY format. For one thing, there is ambiguity among various countries regarding the DD-MM vs MM-DD order. And there is the problem of sorting by date. And the potential for Mars probe crashes.

I am sympathetic with your need to comply with certain date formats, but maybe this could be an opportunity to (gently) nudge your co-workers or presentees to appreciate the YYYYMMDD format :grinning:.

And thanks for @evanfuchs and @jahala for the useful tips.

1 Like

Agreed with @Arthur - interesting problem and kudos to those who provided solutions. I am still perplexed by MM-DD vs DD-MM since I have relatives and coworkers outside the USA. When handwriting dates I write out month names to avoid any confusion.