Convert .docx to .epub with apple pages using command line Pages has an File &gt; Export To &gt; ePub... option that I'm using to manually convert a Word document (which Pages can open directly) to ePub format. 

I'm basically looking for the equivalent of:

/Applications/calibre.app/Contents/MacOS/ebook-convert mybook.docx mybook.epub


For completeness, I want to use Pages instead of Calibre because it does something 'smarter' with one aspect of arabic text that I need: it tags all arabic blocks with dir="rtl".
If you're not married to using Pages and are familiar with the Terminal, you can use Calibre (free and open source) rather easily to do this using their command line interface through the terminal:

ebook-convert myfile.docx myfile.epub


The only slight challenge is finding the ebook-convert script after installing Calibre; typically it's here:

/Applications/calibre.app/Contents/console.app/Contents/MacOS/ebook-convert