Page 1 of 1

Rearranging characters in a folder name

PostPosted: Sat Dec 18, 2021 6:15 pm
by jabrh@comcast.net
I have 2,000+ folders of photos, each named in the format "MM-DD-YYYY [Description]". The problem is that I cannot sort these chronologically, so I would like to rename the folders "YYYY-MM-DD [Description]". Is there a way to make this change in bulk?

MM-DD-YYYY [Description] ===> YYYY-MM-DD [Description]

PostPosted: Sun Dec 19, 2021 12:35 pm
by Luuk
With RegEx(1) the "Match" and "Replace" can be like...
^(\d\d-\d\d)-((19|20)\d\d)( \[.+\])$
\2-\1\4

Re: Rearranging characters in a folder name

PostPosted: Fri Dec 31, 2021 7:07 pm
by jabrh@comcast.net
Thank you, Luuk.
I have not used this utility before, so I would appreciate a little clarification. Do I put that full string in both fields ("Match" and "Replace") or does part go in one field and part in another?
I appreciate your help.
Alan

Re: Rearranging characters in a folder name

PostPosted: Fri Dec 31, 2021 7:54 pm
by jabrh@comcast.net
Luuk - I now believe that the "Match" text string was on the first line and the "Replace" string was the second line. I've tried this, and when I "Preview" am told "There are no selected items that need renaming"

Any thoughts?

Thanks again.

Re: Rearranging characters in a folder name

PostPosted: Fri Dec 31, 2021 8:13 pm
by therube
Another method...

1:RegEx, enable: Simple:
Code: Select all
Match:  %1-%2-%3 %4
Replace:  %3-%1-%2 %4


%1 matches Month (more generally, anything up to the first dash [-])
%2 matches Day ...
%3 matches Year ...
%4 matches everything else

And with that, it's just a rearrange of the parts...

Code: Select all
01-01-2022 [Description]123
->   2022-01-01 [Description]123
12-31-2021 [Description]123
->   2021-12-31 [Description]123

Re: Rearranging characters in a folder name

PostPosted: Fri Dec 31, 2021 8:24 pm
by therube
What I posted is fairly general.

What Luuk posted is more exacting & is looking for a "description" that is actually (prefaced by a spaced &) enclosed within [ ] (with nothing at all following).

So with my example files, their would be no matches found.
If I remove the 123 from the end of the filename, then it would work as wanted.

Luuk's could be more generalized too.
Code: Select all
Match:  ^(\d\d-\d\d)-((19|20)\d\d)( .*)$

The ( .*)$ simply says, accept a space and anything else that follows.
If you change it to (.*)$, then the space is not even needed, so "01-01-2022[Description]" would also match.

Re: Rearranging characters in a folder name

PostPosted: Fri Dec 31, 2021 9:22 pm
by jabrh@comcast.net
Thank you so much therube! At first yours didn't work, and then I checked off the "Simple" box and it did. And your explanation helped me realize what I was doing wrong with Luuk's advice. When I originally asked my question, I put the word Description in square brackets. I didn't intend this to mean that I was using the square brackets in my naming convention - I was simply trying to delineate. Once I adjusted Luuk's script to exclude the square brackets, his worked too. And now I have become pretty good at understanding how this all works too!