#1 2009-05-20 01:46

vhartman
Member
Registered: 2009-05-20
Posts: 3

Put in comma after all surnames

I have about hundred of Ebooks: Surname 1 2 or 3 First names after that i have the "- "and then the books name.
Now I will put in the comma after the surname. I have tried a lot but it doesn't work for me.

for ex (\w+)
and replaces with $1,

the result is that after every single word it is a comma.

How can I made this correct?

Sorry for by bad english.

Greatings from sweden and thanks for a fantastic program.

Jürgen

Offline

#2 2009-05-20 02:22

prologician
Member
Registered: 2009-01-30
Posts: 84

Re: Put in comma after all surnames

As you already discovered, the Regular Expression filter matches the what it can, and after performing the replacement operation, it will try to match again with the remainder of the filename.

I have no doubts that this can be done with a regular expression (and with some legwork, I could cook it up.... maybe krtek will volunteer one? wink ), but this may be easiest with a different filter.

How about the Replace filter:

Find: ' ' (Just put a single space into the Find box)
Replace: ', ' (Comma-space)
Occurrences: first

Offline

#3 2009-05-20 10:15

vhartman
Member
Registered: 2009-05-20
Posts: 3

Re: Put in comma after all surnames

Oh thanks for this help, I will try it out to night when I comes home.
If it works I will tell you.
Have a nice day and thanks again.

Greatings from Sweden
Jürgen

Offline

#4 2009-05-20 10:27

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Put in comma after all surnames

Surname    1 2 3 - the books name
(Surname) (1 2 3 - the books name)
(.+?)         (.+)


(.+?) (.+)
$1, $2


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#5 2009-05-20 17:41

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: Put in comma after all surnames

I would use at least four rules as a solution.

There is a problem of hyphen in that case. Cause hyphen can be a part of Surname Curie-Sklodowska and it can be a part of title as well. What makes it "that" hyphen is that it is the first hyphen with two spaces arround (" - "). But this is not a very good stop point for our search. It will be much easier with one-char. So let's replace it with * at the beginning and thenbackwards at the end.

1. Replace rule
Find: " - "
Replace: "*"
Occurence: First

2. Regex rule
Expression: "([^,]+)\s([^*,\s]+)([*,])"
Replace: "$1, $2$3"

3. Regex rule
Expression: "([^,]+)\s([^*,\s]+)([*,])"
Replace: "$1, $2$3"

4. Replace rule
Find: "*"
Replace: " - "
Occurence: First

The above set is for maximum 3 Surnames.
Rules 2 and 3 are identical. Every time you add one more such rule the number of Surnames possible to be processed increases by 1.
So if the maximum number of Surnames is 5 you will need 2 more such rules...

Last edited by krtek (2009-05-20 17:50)


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

#6 2009-05-20 19:46

Stefan
Moderator
From: Germany, EU
Registered: 2007-10-23
Posts: 1,161

Re: Put in comma after all surnames

Don't make it that complicated krtek.
One can make toooo much sometimes, and the novice user will be confused for that.

And i guess whit your 1. Replace rule the user get an warning message.

Last edited by Stefan (2009-05-20 19:47)


Read the  *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)

Offline

#7 2009-05-20 20:26

krtek
Senior Member
From: Łódź (Poland)
Registered: 2008-02-21
Posts: 262

Re: Put in comma after all surnames

It's not so complicated tongue
There is no warning message as there is no "*" in the end of the process.

With your (or Prologicians, cause their exactly the same) solution you need to separate files with different number of surnames. Otherwise you can get "Ilf,, Petrow - Twelve Chairs".
In my set of rules you replace " " (space) with ", " but only between the beginning of the filename and the " - " (author - title separator). And only if there is more than one author.
Your rules give "Wharton, - Birdy" instead of "Wharton - Birdy".
That's why I made it a bit more complicated wink

Last edited by krtek (2009-05-20 20:26)


Regular Expressions are not as hard to understand as you may think. Check ReNamer's manual or nice Regular Expressions tutorial for more info and start to use full power of applications that use them (like ReNamer, Mp3Tag and so on).

Offline

Board footer

Powered by FluxBB