"Say you just bought an Amazon Kindle or a Barnes and Noble
Nook. You want to convert your eBook collection to .EPUB or .MOBI
format. For this, install Calibre. The application not only
provides you with a graphical way to manage your eBook collection,
but also comes with a set of useful command-line tools. One of
these is ebook-convert.
"This tool can help you convert between tens of standard formats
like EPUB, FB2, LIT, LRF, MOBI, OEB, PDB, PDF, PML, RB, RTF, TCR,
TXT, HTML and more."