Change name from YYMMDD to YYYY-MM-DD

I am sorry that my post triggered you. Certainly not my intention.

3 Likes

Some months ago I installed a command-line tool called rename via brew. I also have this for Linux.

It is a tool for doing renames of files using Regular Expressions. In that case it is more helpful than the rename features available in the Finder. Though it is barely possible that the files could be renamed in the search-and-replace part of rename in the finder.

For my own documents, the ISO style date of YYYY-MM-DD is very important since my documents do span the centuries and I want them to be sorted properly. Items like letters and articles start with this so I can find them in an orderly manner.

Regular Expressions can certainly look intimidating at first. Take it a little at a time. Often you are trying to select some range of characters and have one or more of that pattern.

So, for example, if you were just interested in picking out a numeric digit, you could use

[0-9]

Sometimes this can be replaced with

\d

as a shorthand.

If you want two of these you could use

[0-9][0-9]

or

\d\d

or even

[0-9]{2}

\d{2}

If you want an arbitrary number of digits but at least one then you could use:

[0-9]+

The parens I see in some of the examples tells RegEx to store values in a location for later use.

It helps to have a sandbox to play with RegEx and https://regex101.com/ is one of them that has been mentioned before. You can put your sample file names and build a RegEx and see how it affects the input text.

The O’Reilly book called Mastering Regular Expressions is the resource most people refer to when they are not looking at some online source. Sometimes it can become very complex, especially when you get to things like back references. I have to look those up to get them right.

The explanation of the RegEx on the RegEx101.com site can be helpful for learning as well.

Looks like you have something for your immediate needs but once you know a tool is there, you may want to find other uses for it.

James D. Keeline

1 Like

Thanks so much for all the tipps!!!