【问题标题】:Powershell Pandoc Batch Processing Current DirectoryPowershell Pandoc 批处理当前目录
【发布时间】:2020-01-11 00:41:35
【问题描述】:

我已经搜索了无数线程,例如这个Mac Tutorial 和这个看似相关的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 个文档要转换,并且迫切需要帮助!

【问题讨论】:

  • 这不是powershell命令,这是Windows CMD命令
  • 感谢您的澄清。我不熟悉 Windows 批处理或 PowerShell 脚本,也无法发现明显的区别 :-)

标签: powershell docx pandoc


【解决方案1】:

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

PowerShell 翻译为:

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

【讨论】:

    猜你喜欢
    • 2013-06-08
    • 1970-01-01
    • 1970-01-01
    • 2018-01-21
    • 2012-05-06
    • 2011-05-24
    • 2014-09-03
    • 2011-07-05
    相关资源
    最近更新 更多