Ulysses ePub fix – Script Update

This morning I received an email from the Ulysses developers about the ePub bugs I reported. One thing that surpised me was a request to update my script that fixes the playOrder incrementing.

One thing that came to my mind: since you already developed a small Ruby script, could you integrate the unzip and zip process within the script, so users wouldn't need this extra step anymore? — Götz

So I did!

Now the script can be run with a zip and unzip options.

$ epub-fix.rb unzip book.epub 


$ epub-fix.rb zip book.epub 

The unzip option will unpack the ePub file and then send the toc.ncx file to the rest of the script for incrementing. This will be printed to the terminal for inspection. If it looks good, go ahead and fix the OPS/toc.ncx and save it to a new file. I didn’t automate this step because the file needs to be looked at.

$ epub-fix.rb OPS/toc.ncx > new.toc

To save a step, the file can be saved when unzipping.

$ epub-fix.rb unzip book.epub > new.toc

The new file can then be moved into place with the following command.

$ mv new.toc OPS/toc.ncx

Then the file can be zipped up with the script.

$ epub-fix.rb zip book.epub 

If everything worked, this message will be printed.

freshening: OPS/toc.ncx (deflated 59%)

Now the .epub file is all packed up and ready to be verified.

The script now lives on GitHub:

Note: Just to save ruby from puking error messages, there’s a generic “Oops” error now. If that shows up it usually means there’s either not enough or too many command line options.