Change in filename

A swapping-ground for Regular Expression syntax

Change in filename

Postby 44xav44 » Tue Jan 30, 2018 8:57 pm

Hello,

I have a regex problem that i don't understand

I want to rename a lot of filename like this :

Before
NAME 1 NAME 2 - TITLE1 TITLE2 TITLE3.epub

After
NAME2, NAME 2 - TITLE1 TITLE2 TITLE3.epub

I just want to invert NAME1 WITH NAME 2 and keep everything else like it was.
i can have many words TITLEx

I have tried
Match (.*) (.*) - (.*)
Replace \2, \1 - \3

But my "title part" is always incomplete, i miss the last part of the title.

Could someone could help me ?
It makes me crazy because it does not seem difficult but :shock: :shock:

Thanks !
44xav44
 
Posts: 3
Joined: Tue Jan 30, 2018 8:44 pm

Re: Change in filename

Postby therube » Tue Jan 30, 2018 9:26 pm

But my "title part" is always incomplete, i miss the last part of the title.

Could you give some examples of that, the missing part.
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Change in filename

Postby 44xav44 » Tue Jan 30, 2018 11:21 pm

Yes of course :

Before
AGNES LEDIG - JUSTE AVANT LE BONHEUR.epub
I would like this after Regex :
LEDIG, ANNE - JUSTE AVANT LE BONHEUR.epub

because with
(.*) (.*) - (.*)
and \2, \1 - \3

i get : LEDIG, ANNE - JUSTE AVANT LE .epub

i lost the last word before .

Much thanks for your help !
44xav44
 
Posts: 3
Joined: Tue Jan 30, 2018 8:44 pm

Re: Change in filename

Postby therube » Wed Jan 31, 2018 5:18 am

Oh, I asked for an example, because I thought what you had done looked right.

Thinking you have an extraneous <space> after the closing paren, ) .
therube
 
Posts: 1314
Joined: Mon Jan 18, 2016 6:23 pm

Re: Change in filename

Postby 44xav44 » Wed Jan 31, 2018 6:34 am

Ok it worked.
Again, thanks a lot :D :D
44xav44
 
Posts: 3
Joined: Tue Jan 30, 2018 8:44 pm


Return to Regular Expressions


cron