Any changes made at file level are effectively lost but you can still salvage the calibre library. First and foremost, create a back-up of metadata.db and keep it somewhere safe. I'd do multiple backups just to be extra safe. I know I've overwritten my backup with a bad/corrupt copy on occasion.
Then, assuming your books are in the following:
Code:
\Calibre Library\A\Author A\Title (id)\Title - Author A.ext
\Calibre Library\Z\Author Z\Title (id)\Title - Author Z.ext
Move the authors back to the top level so you have:
Code:
\Calibre Library\Author A\Title (id)\Title - Author A.ext
\Calibre Library\Author Z\Title (id)\Title - Author Z.ext
Then run Calibre and do:
Library maintenance -> Check library -> Do you want calibre to check if the files in your library match the information in the database? Yes
Don't run any of the fixes. Instead expand the results so you can rename the files and folders you changed back to their original names in Windows Explorer or Finder (or whatever you use as file manager).
If you've made more massive changes to the directory and file structure than the above such as removing (id) you're better off copying the library to a different location and re-importing with merge duplicates.