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?

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).

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).

i have been trying to change filenames 1) to 2) use the 'Search and Replace Tab' as discribed above method with a few variations but without any success.

as there is no , between the fisrt and last name i just can't get the [Regular Expression] to work.

any help could be much appreciated. many thanks in advance.

Do you have these as "filenames" as posted above, i.e., not yet imported into Calibre, or have you already imported incorrectly and are in a field, like author or title? If they are still files, and you want to import them correctly, you use regex in the Add Books Preferences, while if they are already in the wrong field, you use Search and Replace.

Do you have these as "filenames" as posted above, i.e., not yet imported into Calibre, or have you already imported incorrectly and are in a field, like author or title? If they are still files, and you want to import them correctly, you use regex in the Add Books Preferences, while if they are already in the wrong field, you use Search and Replace.

oh, i see. thanks for the clarification.

actually, i have both. some are already there and some are ready to Ádd, but i just cant get the regex to work correctly.

I reread your post, and it looks like you want to swap first name and last name in some cases. You need to get your author names all consistent and your author_sort all fixed. From then on you can use the regex I gave you to bring in the author correctly and the author_sort will fix itself. Start by fixing or reimporting everything you have now. From then on, you can import correctly and all should be fine.

I reread your post, and it looks like you want to swap first name and last name in some cases. You need to get your author names all consistent and your author_sort all fixed. From then on you can use the regex I gave you to bring in the author correctly and the author_sort will fix itself. Start by fixing or reimporting everything you have now. From then on, you can import correctly and all should be fine.

You're welcome, but I got you only part of the way. You'll want to decide whether you want your authors all to appear as LN, FN or FN LN. Then you want to set your tweaks so that the author_sort is set correctly when you bring in new books. (In case you aren't familiar with it, author_sort controls how your authors are sorted) Look in Preferences for the new and improved Tweaks setting screen. You may need to use Search and Replace to fix any errors you have now, but once all that's set, you won't have to use it again.

It should work for both, but you need to turn on the swap author FN LN option for the second group. (I assume you want to keep the "a novel" in the title.)

For those that are already in, you'll need to provide more info about what field they are in.

Quote:

Originally Posted by Starson17

You're welcome, but I got you only part of the way. You'll want to decide whether you want your authors all to appear as LN, FN or FN LN. Then you want to set your tweaks so that the author_sort is set correctly when you bring in new books. (In case you aren't familiar with it, author_sort controls how your authors are sorted) Look in Preferences for the new and improved Tweaks setting screen. You may need to use Search and Replace to fix any errors you have now, but once all that's set, you won't have to use it again.

Feel free to ask if more help is needed.

Good luck!

sorry starson17, spoke too soon. isn't that the same as the default setting?

so, what regex do i need to put into the 'search and replace' to 17 to the same as the other 33?

There isn't any regex that will split the FN and the LN, and reverse some, but not others. Use the regex I gave you (default) for all the FN LN format files, then click the option that reverses FN and LN (it's on the Add books regex page) and import the other group. That gives you files all in FN LN format, which is what Calibre expects. (It will create an author_sort field that is LN, FN and use it for sorting).