Calibre does not keep track of the last time you opened a book, but your filesystem does. Or at least, it kinda does. Thankfully you can use Calibre template functions and custom columns to make use of this information.
- Go to
Preferences -> Advanced -> Template Functions
- Select the
Function
field at the bottom left of the window - Type
last_accessed
and give it some documentation if you like - Set
Argument count
to-1
because the required arguments have everything we need - In the
Program code
box on the right, paste this code (you may have to fiddle with the indentation):
def evaluate(self, formatter, kwargs, mi, locals):
from os import stat
from time import ctime
book_paths = [f['path'] for f in mi.get('format_metadata', {}).values()]
atimes = map(lambda f: stat(f).st_atime, book_paths)
most_recent = max(atimes)
return ctime(most_recent)
- Click
Create
at the bottom center (orReplace
if you messed up the first time!) - Click
Apply
at the bottom right
- Go to
Preferences -> Interface -> Add your own columns
- Click
Add custom column
at the bottom - Click
Formats
in theQuick Create
line at the top of the dialog window - In
Lookup name
enterlast_accessed
- In
Column heading
enterLast Accessed
(orLast read
, etc.) - Give it a description if you like
- In the
Template
field, enter{:'last_accessed()'}
- Set the
Sort/search column by
dropdown toDate
- Click
OK
to close the custom column dialog - Click
Apply
to finish adding the column
The changes you made will take effect when Calibre restarts. If it did not prompt you already, just close and reopen it. You can now sort books by the last date you watched them!
The column I've created seems to be only visible in the library currently loaded, is there a way to make custom column visible to all existing libraries ? Thank you Andrea