Swap charactors position in file name?

A swapping-ground for Regular Expression syntax

Swap charactors position in file name?

Postby rbendett » Sun Feb 26, 2006 1:41 am

Is it possible to swap the first four charactors of filename with the last four?
Example: 02252006.jpg to 20060225.jpg
rbendett
 
Posts: 2
Joined: Sun Feb 26, 2006 1:36 am

Postby Stefan » Sun Feb 26, 2006 1:52 pm

Yes, with regular expressions,
this depends on your file names.
In this case,
Example: 02252006.jpg to 20060225.jpg
you could use this reg ex:

Find:
02252006.jpg
(....)(....) -------- read as: find 4 chars and group them in (), than find another 4 chars and group them also in ().

Replace with:
\2\1 -------------- read as: build your new name by wrote the second group first, followed by the first group.
20060225.jpg



So try this in the top left RegEx field:
FIND: (....)(....)
REPALCE: \2\1



One DOT stands for any character.
Instead of "(...)" you could use "(.{4})" also, i don't know if this works in BRU?
All found with the search between the two brakes () stands for one group.
Then you can access this groups later with "\#" like \1 or \2
Please see the the regex help for details...or ask again if unclear.
Stefan
 
Posts: 736
Joined: Fri Mar 11, 2005 7:46 pm
Location: Germany, EU

Postby rbendett » Sun Feb 26, 2006 4:46 pm

Thanks, it works.
rbendett
 
Posts: 2
Joined: Sun Feb 26, 2006 1:36 am

Postby Admin » Sun Feb 26, 2006 8:01 pm

Thanks Stefan!

Jim
Admin
Site Admin
 
Posts: 1465
Joined: Tue Mar 08, 2005 8:39 pm


Return to Regular Expressions


cron