Updated December, 2021
This is a very quick-and-dirty method to pull all the books that Amazon knows you have bought or borrowed for your Kindle. There are various ways to export the list of purchased books from Amazon but I read a lot of e-books from the library and couldn’t find a way to export those. (Dec, 2021 Update: Fixed code after Amazon revamped their layout – thanks for letting me know, Robin!)