Folder rename DDMMYYYY to YYYYMMDD

A swapping-ground for Regular Expression syntax

Folder rename DDMMYYYY to YYYYMMDD

Postby gocyclones » Thu Jul 17, 2014 4:55 pm

I have a large amount of folders that I need to rename as I'm reorganizing my photos. They are currently in the format DDMMYYYY and I want to get them renamed to YYYYMMDD. Examples are:
01JAN2009 -> 2009JAN01
02JAN2009 -> 2009JAN02
13NOV2013 -> 2013NOV13

Can anyone help me out.

gocyclones
gocyclones
 
Posts: 2
Joined: Thu Jul 17, 2014 4:46 pm

Re: Folder rename DDMMYYYY to YYYYMMDD

Postby gocyclones » Thu Jul 17, 2014 5:21 pm

And to answer my own post.
Match (\d{2})(.*)(\d{4})
Replace \3\2\1
gocyclones
 
Posts: 2
Joined: Thu Jul 17, 2014 4:46 pm

Re: Folder rename DDMMYYYY to YYYYMMDD

Postby truth » Fri Jul 18, 2014 4:59 pm

Glad you found a solution.
For the given examples, its quick & efficient.
I often do something similiar when name-formats dont change.

If anyone has multiple name formats, use with caution, especially with filenames:
Group1 matches 1st 2Digits anywhere in Origname
Group2 matches either AnyText/NoText until
Group3 matches Last 4Digits anywhere in Origname

So while text from \1 to \3 is matched & re-ordered,
text outside that range is removed from Newname:
Text12abc3456Text -> 3456abc12
aa123456zz ----------> 345612
000003 ---------------> 000300

As an example, here's a more specific match:
^(\d\d)([A-Z]{3,4})(\d{4})$

The ^ ensures Origname starts with 2Digits
The $ ensures Origname ends with 4Digits
Group2 matches AllText-inbetween only if 3or4 UpperCases

Its been a pleasure posting to this board, sorry I didnt have more time.
It'll prob be quite a while before I can internet again, good luck to all.
truth
 
Posts: 221
Joined: Tue Jun 25, 2013 3:39 am
Location: Earth, OrionArm, MilkyWay

Re: Folder rename DDMMYYYY to YYYYMMDD

Postby Admin » Tue Jul 22, 2014 12:32 pm

Thank you Truth, make sure to check back in when you can!
Your help has been fantastic for all BRU users!
Admin
Site Admin
 
Posts: 2343
Joined: Tue Mar 08, 2005 8:39 pm


Return to Regular Expressions