Skip to content

Instantly share code, notes, and snippets.

@percursoaleatorio
Created July 28, 2014 12:56
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save percursoaleatorio/6925a51440bae7bb509d to your computer and use it in GitHub Desktop.
Save percursoaleatorio/6925a51440bae7bb509d to your computer and use it in GitHub Desktop.
Convert from docx to restructured text
@echo off
rem nery[_at_]tecnico.ulisboa.pt v2014.01.16 [CC BY-NC-SA]
rem OBJETIVO: Converter de DOCX para RST utilizando o CALIBRE e o PANDOC.
rem Criar ficheiro de texto com o mesmo nome e extensão *.rst
rem PRE-REQUISITOS:
rem C:\Users\nery\AppData\Local\Pandoc\
rem C:\Programs\Calibre\Calibre Portable\Calibre
rem REFERENCES
rem http://manual.calibre-ebook.com/cli/ebook-convert.html
rem http://johnmacfarlane.net/pandoc/README.html
rem http://digitalpublishingtoolkit.org/2013/08/docx-to-markdown-using-calibre-and-pandoc/
rem Demo file
rem http://calibre-ebook.com/downloads/demos/demo.docx
@echo on
for %%f in (*.doc?) do (
setlocal enableDelayedExpansion
mkdir temp
copy "%%f" temp
cd temp
"C:\Programs\Calibre\Calibre Portable\Calibre\ebook-convert" "%%f" output.htmlz
unzip output.htmlz
cd ..
pandoc -f html -t rst --output="%%~nf.rst" temp/index.html
rm -R temp
endlocal
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment