Batch processing Pandoc conversions in Windows

匿名 (未验证) 提交于 2019-12-03 08:46:08

问题:

I am trying to convert a large number of HTML files into Markdown using Pandoc in Windows, and have found an answer on how to do this on a Mac, but receive errors when attempting to run the following in Windows PowerShell.

find . -name \*.md -type f -exec pandoc -o {}.txt {} \; 

Can someone help me translate this to work in Windows?

回答1:

to convert files in folders recursively try this (Windows prompt command line):

for /r "startfolder" %i in (*.htm *.html) do pandoc -f html -t markdown "%~fi" -o "%~dpni.txt" 

For use in a batch file double the %.



回答2:

Endoro's answer is great, don't get confused by the parameters added to %i.

For helping others, I needed to convert from RST (restructured text) to dokuwiki syntax, so I created a convert.bat with:

FOR /r "startfolder" %%i IN (*.rst) DO pandoc -f rst -t dokuwiki "%%~fi" -o "%%~dpni.txt" 

Works for all rst files in folders and subfolders.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!