0

I have scoured countless threads such as this Mac Tutorial and this seemingly relevant Powershell Tutorial to no avail. Currently, I am attempting to run

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

to convert all .docx to .md within the current directory. Unfortunately when running this from the Powershell ISE I am met with the following message

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

Please advise on how to convert a directory full of .docx files to .md using powershell. I have around 250 docs I would like to convert and am in desperate need of assistance!

Andrew Pynch
  • 190
  • 1
  • 9

1 Answers1

2

As Shamus Berube points out, your command uses (broken) cmd.exe syntax, not PowerShell syntax.

The PowerShell translation is:

Get-ChildItem -Recurse -Filter *.docx | ForEach-Object {
  pandoc -o ($_.FullName + '.md') $_.FullName
}
mklement0
  • 382,024
  • 64
  • 607
  • 775