Originally Posted by Barriemackenzie
I have just imported all my books into Calibre and unfortunately some but not all of the author names are written 'Smith, John' and Calibre is assuming that John is the last name and sorting by John. I cannot see anyway to rectify this without individually editing all the names. Is there a script/plugin to do this?
How is your Regex knowledge?
The "simple" way to do this is to select ONLY the books that have the authors first and last names reversed, and perform a bulk metadata edit (press the E key after Ctrl Selecting the books you want to fix).
Then Go to the Search and Replace Tab.
Select [Authors] in the Search Field
Select [Regular Expression] in the Search Mode drop-down Field.
In the Search for: field enter (.*), (.*)
In the Replace with: field enter \2 \1
(check in the Test results table that the expected reversal will take place)
Make sure you have selected ONLY the books with the reversed names!
Make Sure you have backed up your library !!
Cross your fingers
Then Click OK
Calibre will update the Author-Sort field automagically at the same time.
The regular expression shown (.*), (.*) will only work for authors that are entered as LastName, FirstName i.e. it expects one comma and one space between a single last name and (one or more) first name(s).