When there is a very large mismatch between what files are in a Calibre library and what Calibre thinks should be there then the easiest way to recover is typically something along the lines of:
- Use the Calibre facility to move the library to a new location. This will move all the files/folders that Calibre knows about to the new location.
- Look at what has been left behind with a view to adding back any items that you think should be in your Calibre library
This does not explain why your library seems to have got messed up in the first place. Reasons I have come across are:
- Storing the Calibre library on Cloud based storage. If you ever run Calibre from two locations at the same time or if the sync process interferes with a running instance of Calibre then library corruption can occur.
- Storing the Calibre library on a network drive. This works a lot of the time but it is not officially supported as things occasionally go wrong.
- Storing the Calibre library in Google Drive. This can mess up a Calibre library by silently renaming folders with numbers in brackets (as used by Calibre).
- Any manual manipulation of the files stored in the Calibre library bypassing the Calibre GUI.