Powershell Pandoc批处理当前目录

Powershell Pandoc Batch Processing Current Directory

我搜索了无数线程,例如这个 Mac Tutorial and this seemingly relevant Powershell 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 个文档要转换,并且迫切需要帮助!

正如 Shamus Berube 指出的那样,您的命令使用(损坏的)cmd.exe 语法,而不是 PowerShell 语法。

PowerShell 翻译为:

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