There's no need for this, if you're using AwesomeMod, there is already a command, regeneratebooks, or something, that will regenerate all library shelves.
Unfortunately that doesn't work since the library lacks the "Book Corral" shelf that holds the missing books. I added a different version with the missing bookshelf so in the future regeneratebooks will fix the problem if the books go missing.