Swap Last Two [or more] words of Filename.

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

Swap Last Two [or more] words of Filename.

Postby FOL » Sun Aug 28, 2011 1:32 am

Hi there,

Could someone help me switching the positioning of the last two words in a filename please... Ex:

< A book - Author, An
> A book - An Author

I've tried the RegEx code [which didn't change anything]:

RegEx(1)
MATCH: (.+), (.+)( - .+)
REPLACE: \2 \1\3

If possible, could someone please also help solving the same issue but with more than two words [3,4 or more words]... Ex:

< A book - Author, An Acclaimed And Noteworthy
> A book - An Acclaimed And Noteworthy Author
FOL
 
Posts: 1
Joined: Sun Aug 28, 2011 1:03 am

Re: Swap Last Two [or more] words of Filename.

Postby Stefan » Mon Aug 29, 2011 7:01 am

Hi FOL

you need to have one common pattern for all file names.
Our anchors will be SpaceDashSpace and the coma.

Let's try with
( 1: All signs till SpaceDashSpace, stored in group 1 )
( 2: one single word, stored in group 2 )( 3: an coma, which we will drop )
( 4: one space and the rest, stored in group 3 )

and replace by \1\3\2


FROM:
A book - Author, An
A book - Author, An Acclaimed And Noteworthy
TO:
A book - An Author
A book - An Acclaimed And Noteworthy Author

RegEx(1)
MATCH: (.+ - )(\w+),( .+)
REPLACE: \1\3\2


Please try and report back.

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


Return to BRU Support