As ebook readers have become more and more popular over the past few years, there have cropped up numerous websites that make purchasing and downloading ebooks incredibly simple. The already existing Project Gutenberg website, for instance, which already made tens of thousands of books available as txt and html files, now makes those same books available in formats ready for reading on the Kindle, Nook, and other popular ebook devices. In addition, some websites that sell ebooks also make available – for free – public domain books. Among those websites are Feedbooks, the Amazon Kindle Store, and more.
Of course, sometimes – especially with free books – you may find errors. Sometimes the formatting of a book has gotten off kilter, while other times there are spelling errors. We’ve previously shown how to install and create ePub files with a program called Sigil that makes it simple to edit your ePub files, but it’s also possible to perform very basic edits using nothing more than an archiving program and a text editor. Here’s how.
First, let’s grab a free ePub from Feedbooks, so we’ll have something to edit. We’ll grab the copy of “War Of The Worlds,” by H.G. Wells, located at this link.
Simply click the EPUB link to the right, and download your book. We downloaded our copy to the Desktop. Once downloaded, we need to make a simple change. Rename the ePub file so that its extension is no longer .epub, but uses the .zip extension.
Now that we have the extension changed, simply unzip the archive.
You should now have a folder with the same name as your ePub file. It will be called “H. G. Wells – The War of the Worlds” if you grabbed the same ebook we did.
Inside this archive you’ll find three items. There is a document called “mimetype” and two folders, named META-INF and OPS.
The html or xhtml files that make up the ePub are located in the OPS folder, along with other folders, such as css and images. Since most ePub files you’ll find will split up each chapter into its own html or xhtml file, you’ll likely be able to tell which file makes up a specific chapter, but you may need a bit of guesswork to get it right. Once you’ve found the correct document, you can open it in your favorite text or html editor. In our example we’re using a Linux text editor called Medit, but you can use whichever you prefer.
Once opened, simply make the changes you want.
When done, simply save your changes to the document. When you’ve made all the changes you want, it’s time to recreate the zip archive (which we’ll later modify by changing the extension back to .epub from .zip).
So, go ahead and open your archive manager. In Linux, you can use File Roller (the default for GNOME), Ark (the default for KDE), and Xarchiver (the default for Xfce). In the screenshot below, you’ll see Xarchiver.
Now, use the toolbar or menu to create a new archive.
You’ll also need to give it a name.
We now need to add our files back into the new archive.
IMPORTANT: We need to ensure two things when adding files into our new zip archive. First, the mimetype document needs to be added first (to ensure all ebook readers notice it before trying to parse through the other files inside), and second, the mimetype document needs to be added uncompressed (you may see it called “stor” mode).
When finished, simply close your archive manager (being sure to save the archive if your program doesn’t automatically save changes). You should now have a new zip archive on your desktop, which we’ll now rename with the .epub extension.
Note: be sure that your “old” and “new” zip archives and epub files don’t have identical names, or you’ll run into naming conflicts.
You can now test the newly edited epub in your favorite software.
And that’s it! This method of editing an epub works just fine for small jobs. However, should you need to perform massive changes, such as changing file names (inside the epub), adding or removing photos or changing meta-data, then Sigil is probably a better choice. For simple jobs, however, this is quick and easy, and doesn’t require installing any additional software.