View Single Post
Old 10-16-2022, 01:04 PM   #8
DaltonST
Deviser
DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.
 
DaltonST's Avatar
 
Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
JS Tool for You

Quote:
Originally Posted by the_Pan View Post
Hi folks!

Because I have a problem with one of the Calibre plugins, I deleted several of my self created columns to test if that helps - of course without backup.
(I backed up the ~/.config folder (Linux), but I wasn't aware, the metadata is stored in a different folder).

Is it still somehow possible to restore the deleted columns?

Before you start flailing, there is an "easy" way to restore your custom column data from an old metadata.db database that you have.


[1] View Job Spy thread: https://www.mobileread.com/forums/sh...18&postcount=1


[2] Look at the Tool named "Import Metadata from CSV File". An image is attached here for your convenience.


[3] Read the Tool's ToolTips by hovering your mouse everywhere in its dialog box for all of its widgets.


[4] Open your "old" metadata.db with Calibre.


[5] Use the Calibre "create catalog" function, specifying as a minimum the Book ID and the Custom Columns that you wish to restore.


[6] Export the Catalog to a .csv file.


[7] Open the .csv file in Calc/Excel (NOT a text editor) to ensure it has what you want in it. Ensure that all of the cells are "text", including Book ID. Create Column Header Names if they are missing. The Tool uses the Header Names. Remember to save the .csv as a UTF-8 file when saving the file as a .csv (e.g. Save Filter option in Calc).



[8] Run Calibre. Quick Switch to your "broken" Library.


[9] Recreate your missing custom columns, which will of course be empty. Restart Calibre. Back up your new metadata.db AFTER restarting.


[10] Click the JS Icon dropdown menu arrow, and navigate to the Metadata submenu to find the "Import Metadata from CSV File" tool. Run it.


[11] Point it to your new, valid .csv file as described and generated above.


[12] "CSV Column Values to Match" is Book ID. "CSV Column Values to Import" from the .csv data is the first custom column to repair. "Target to Update" that same first missing custom column that you just created. "Match Expression" should be "EQUALS".


[13] Execute in "Preview" mode, which is a "pretend" execution so you verify that the .csv's Book IDs match a large subset of your broken Library.


[14] You should specify via the criteria that you only update certain or selected books. Do a few, then examine a few to verify all is well.


[15] Update all matched books for that first custom column, and then repeat the process by only changing the "source" and "target" .csv columns for the other custom columns. Always execute in "Preview" before doing it for real. No need to reimport the .csv file unless you need to make changes to it in Calc/Excel. Remember to save the .csv as a UTF-8 file when saving the file as a .csv (e.g. Save Filter option in Calc).




DaltonST
Attached Thumbnails
Click image for larger version

Name:	js_import_csv_to_update_metadata_20191023.jpg
Views:	242
Size:	1.24 MB
ID:	197200  

Last edited by DaltonST; 10-16-2022 at 01:14 PM.
DaltonST is offline   Reply With Quote