Rearranging characters in a folder name

Post any Bulk Rename Utility support requirements here. Open to all registered users.

Rearranging characters in a folder name

Postby jabrh@comcast.net » Sat Dec 18, 2021 6:15 pm

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?
jabrh@comcast.net
 
Posts: 5
Joined: Sat Dec 18, 2021 6:11 pm

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

Postby Luuk » Sun Dec 19, 2021 12:35 pm

With RegEx(1) the "Match" and "Replace" can be like...
^(\d\d-\d\d)-((19|20)\d\d)( \[.+\])$
\2-\1\4
Luuk
 
Posts: 690
Joined: Fri Feb 21, 2020 10:58 pm

Re: Rearranging characters in a folder name

Postby jabrh@comcast.net » Fri Dec 31, 2021 7:07 pm

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
jabrh@comcast.net
 
Posts: 5
Joined: Sat Dec 18, 2021 6:11 pm

Re: Rearranging characters in a folder name

Postby jabrh@comcast.net » Fri Dec 31, 2021 7:54 pm

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.
jabrh@comcast.net
 
Posts: 5
Joined: Sat Dec 18, 2021 6:11 pm

Re: Rearranging characters in a folder name

Postby therube » Fri Dec 31, 2021 8:13 pm

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
Last edited by therube on Fri Dec 31, 2021 8:25 pm, edited 1 time in total.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Rearranging characters in a folder name

Postby therube » Fri Dec 31, 2021 8:24 pm

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.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Rearranging characters in a folder name

Postby jabrh@comcast.net » Fri Dec 31, 2021 9:22 pm

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!
jabrh@comcast.net
 
Posts: 5
Joined: Sat Dec 18, 2021 6:11 pm


Return to BRU Support