3

I want Pandoc to convert all .docx files in a directory to .md.

This directory has many sub-directories, and sub-sub directories, etc.

I want the output .md files to stay in the same directory (and sub-sub directory, etc.) as the .docx file from which it was converted.

I have tried many variants of this:

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

I am aware that the "./output/" part of the command is specifying that the converted files be put in a directory called "output"

When I remove "./output/" from the command, the output .md files are all placed in the top-level directory from which the command is run. I want these output files to "stay" in the directory that their .docx file is in.

I am using Windows 8 with Cygwin. If the answer requires code (makefile?), I would like the language to be Lisp (obviously, I am not a programmer).

How can I do this?

Community
  • 1
  • 1

1 Answers1

4

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

I believe it should be:

find ./ -iname "*.docx" -type f -exec sh -c 'pandoc "${0}" -o "${0%.docx}.md"' {} \;
Community
  • 1
  • 1