Created
June 22, 2016 06:19
-
-
Save anemochore/5de1632406eff1c5a5a87d10e8e64260 to your computer and use it in GitHub Desktop.
convert html to docx using pandoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
rem first, install pandoc windows installer. see http://pandoc.org/ | |
rem you may edit below extensions... | |
set INPUT_EXT=htm | |
set INPUT_EXT_ALT=html | |
set OUTPUT_EXT=docx | |
:start | |
set OLD_D=%cd% | |
if "%~x1"==".%INPUT_EXT%" goto file_prerun | |
if "%~x1"==".%INPUT_EXT_ALT%" goto file_prerun | |
:folder_prerun | |
set DEFAULT_INPUT_FILE=index.%INPUT_EXT% | |
set DEFAULT_INPUT_FILE_ALT=index.%INPUT_EXT_ALT% | |
set INPUT_PATH=%1 | |
set OUTPUT_FILE=index.%OUTPUT_EXT% | |
cd /d "%INPUT_PATH%" | |
if exist "%DEFAULT_INPUT_FILE%" set INPUT_FILE=%DEFAULT_INPUT_FILE% | |
if exist "%DEFAULT_INPUT_FILE_ALT%" set INPUT_FILE=%DEFAULT_INPUT_FILE_ALT% | |
if not "%INPUT_FILE%"=="" goto run | |
echo *error: a folder was given as input, but no default input file found inside it. | |
goto end | |
:file_prerun | |
set INPUT_PATH=%~dp1 | |
set INPUT_FILE=%~nx1 | |
set OUTPUT_FILE=%~n1.%OUTPUT_EXT% | |
cd /d "%INPUT_PATH%" | |
:run | |
pandoc -o "%OUTPUT_FILE%" "%INPUT_FILE%" | |
if exist "%OUTPUT_FILE%" echo %OUTPUT_FILE% was created! | |
:end | |
cd /d %OLD_D% | |
pause |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment