View Single Post
Old 05-04-2020, 04:16 PM   #521
baskerville
Evangelist
baskerville ought to be getting tired of karma fortunes by now.baskerville ought to be getting tired of karma fortunes by now.baskerville ought to be getting tired of karma fortunes by now.baskerville ought to be getting tired of karma fortunes by now.baskerville ought to be getting tired of karma fortunes by now.baskerville ought to be getting tired of karma fortunes by now.baskerville ought to be getting tired of karma fortunes by now.baskerville ought to be getting tired of karma fortunes by now.baskerville ought to be getting tired of karma fortunes by now.baskerville ought to be getting tired of karma fortunes by now.baskerville ought to be getting tired of karma fortunes by now.
 
baskerville's Avatar
 
Posts: 446
Karma: 305160
Join Date: Aug 2015
Device: Kobo Glo HD, Kobo Aura ONE
Quote:
Originally Posted by 7596ff View Post
Why does "Clean Up" remove all reading states?
This isn't how I would describe the aforementioned action.

Quote:
Originally Posted by 7596ff View Post
I have to remember all of them now since I clicked the button without knowing what it did
I'm sorry to hear that. Did you keep the old `.metadata.json`? If you did, you might be able to extract the reading states from it.

Quote:
Originally Posted by 7596ff View Post
I had assumed that it would remove all reading states and database information for books that were no longer present in the library, for example the Wallabag folder that I had just made its own library.
Your assumption is correct, and I was about to explain how to convert a directory to database…

Here's an example on how to convert a sub-directory of LIBRARY_PATH, here Articles, to a library:

Code:
cd LIBRARY_PATH

jq 'with_entries(select(.value.file.path|startswith("Articles/")))' .metadata.json > .metadata-articles.json
jq 'with_entries(select(.value.file.path|startswith("Articles/")|not))' .metadata.json > .metadata-no_articles.json

jq 'with_entries(.value.file.path |= sub("Articles/"; ""))' .metadata-articles.json > Articles/.metadata.json
mkdir Articles/.reading-states
jq 'keys|.[]' .metadata-articles.json | xargs printf '.reading-states/%016X.json ' | xargs -J % mv % Articles/.reading-states
rm .metadata-articles.json
cp -p .fat32-epoch Articles

mv Articles .Articles
mv .metadata-no_articles.json .metadata.json

And the library settings for this new library are:
Code:
[[libraries]]
name = "Articles"
path = "LIBRARY_PATH/.Articles"
mode = "database"
baskerville is offline   Reply With Quote