Powershell Pandoc批处理当前目录

时间:2020-01-10 15:12:12

标签: powershell docx pandoc

我已经搜索了无数个线程,例如此Here,而这个看上去相关的Mac Tutorial无济于事。目前,我正在尝试运行

for (/r "." %i in (*.docx) do pandoc -o "%~i.md" "%~i")

将当前目录中的所有.docx都转换为.md。不幸的是,当从Powershell ISE运行此程序时,遇到以下消息

Missing statement body in for loop.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MissingLoopStatement

请提供有关如何使用powershell将充满.docx文件的目录转换为.md的建议。我想转换大约250个文档,非常需要帮助!

1 个答案:

答案 0 :(得分:1)

Shamus Berube指出,您的命令使用(无效)cmd.exe语法,而不是PowerShell语法。

PowerShell的翻译是:

Get-ChildItem -Recurse -Filter *.docx | ForEach-Object {
  pandoc -o ($_.FullName + '.md') $_.FullName
}
相关问题