There are many scripts available. I used https://github.com/bellisk/BulkKindleUSBDownloader