Kovidgoyal, add_format won't work unless I already have an ID. I suppose I could re-write everything from scratch and do a loop (lookup to see if book already exists, grab ID if it does and add_format, otherwise just run add), but since all the code is already written and used by the GUI, that seems a bit too much effort.

Thanks, Starson17; that points me exactly where I want to go. I was actually hoping you'd respond to this

I plan to identify the merge records by parsing the following tree:

Code:

Check for Title
If exists,
Check for author
If exists,
Check for format
If exists, end
else
get book ID
merge books
else
add book

I was also thinking of pre-processing with mekk's ISBN code, so the first step could be to check for ISBN and merge if it's found.

As for the "correct naming format", all this test would do is verify that the RE I use properly captures all the expected fields. If everything ends up in the Title field, I know the RE failed and the book file name needs a look before that book gets imported. I could also apply normalization (eg. JRR Tolkien, J.R.R. Tolkien, J. R. R. Tolkien, and Bob Smith, Bob R. Smith, Bob Smith, Jr.) and ensure things like Jr, Esq, Sir, Mr, etc. get handled appropriately by author_sort.

Next time I have a moment, I'll try to write some of these generically in Python so I can use them on the command line but also have available for someone to port to the GUI who is more heavily involved (I don't have much spare time, which is why I'm trying to avoid duplicating effort).