swap dates in file names

A swapping-ground for Regular Expression syntax

swap dates in file names

Postby Edze » Sat Sep 11, 2010 12:00 pm

Hi,

I have some pics with filenames like (day-month-year)
28012005
13061999
11092010

I would like to start with year, then month, then day, so:
20050128
19990613
20100911

I have read about Regular Expressions on this forum, and in the PDF, but I don't know how to do this...

Regards,
Edze
Edze
 
Posts: 1
Joined: Sat Sep 11, 2010 11:55 am

Re: swap dates in file names

Postby Stefan » Sun Sep 12, 2010 2:43 am

Hi Edze,

Edze wrote:Hi,

I have some pics with filenames like (day-month-year)
28012005
13061999
11092010

I would like to start with year, then month, then day, so:
20050128
19990613
20100911

I have read about Regular Expressions on this forum, and in the PDF, but I don't know how to do this...

Regards,
Edze
This depends a little bit on your real file names (you provide no example of your file names)

For example your file name may looks like this:
"all before space 28012005 space something behind.ext"

Try this:
Match all before the date and store this in an group 1 for later reuse ==> (.+)
Match an space ==> ' '
Then match and store in group 2 the day ==> (\d\d)
Then match and store in group 3 the month ==> (\d\d)
Then match and store in group 4 the year ==> (\d\d\d\d)
Match an space ==> ' '
Then match and store in group 5 all after the date ==> (.+)

Now you can use this groups to reorder the output/NewName.


So use
RegEx(1)
Match: (.+) (\d\d)(\d\d)(\d\d\d\d) (.+)
Repla: \1 \4\3\2 \5


.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU


Return to Regular Expressions