使用Pandoc bash将目录和子目录中的所有.docx(递归?)转换为.md

时间:2016-10-31 14:44:37

标签: bash pandoc

我希望Pandoc将目录中的所有.docx文件转换为.md。

此目录有许多子目录和子子目录等。

我希望输出.md文件与转换它的.docx文件保持在同一目录(和子目录等)中。

我尝试了this的许多变体:

find ./ -iname "*.docx" -type f -exec sh -c 'pandoc "${0}" -o "./output/$(basename ${0%.docx}.md)"' {} \;

我知道" ./ output /"命令的一部分是指定将转换后的文件放在名为" output"

的目录中

当我删除" ./ output /"从命令中,输出.md文件都放在运行命令的顶级目录中。我希望这些输出文件能够保持"保持"在他们的.docx文件所在的目录中。

我正在使用Windows 8和Cygwin。如果答案需要代码(makefile?),我希望语言是Lisp(显然,我不是程序员)。

我该怎么做?

1 个答案:

答案 0 :(得分:0)

基于:Converting all files in a folder to md using pandoc on Mac

我认为应该是:

find ./ -iname "*.docx" -type f -exec sh -c 'pandoc "${0}" -o "${0%.docx}.md"' {} \;
相关问题