THE ISSUE
This may just stem from a lack of deep understanding of Windows batch file coding.
I am trying to write a simple one-line batch file that will process every file in a directory using pandoc to convert all doc or docx (MS Word) files to markdown (.md) files. When I run my batch file I get the following error:
pandoc: C:_ALL\_ALL\accomp\testing-accomp-2017.05\20170505.md: openBinaryFile: does not exist (No such file or directory)
I get one of these errors for each file in the directory (around 25, or so).
The directory I'm running my command in looks like this:
C:\_ALL\!accomp\testing-accomp-2017.05
As you can see, for some reason the _ALL
is appearing twice. The path it is showing me isn't right for some reason and I'm not sure if it is a pandoc issue or a CMD batch file programming issue.
MY CODE
Here is the code for my batch file:
@echo OFF
:: [Not sure what this does, but have read that it is necessary]
setlocal enabledelayedexpansion
:: MAIN
FOR /r "." %%i IN (*.doc *.docx) DO pandoc -f rst -t markdown "%%~fi" -o "%%~dpni.md"
:: End with a pause so user can copy any text from screen.
ECHO. Done. Press any key to terminate program
PAUSE>NUL
Now, I'm not certain what all these lines of code do, and they may be entirely unnecessary for all I know. However, the main and most important code here is the one that starts with For ...
, which is inspired by this Stack Overflow post:
WHAT I'VE TRIED ALREADY
Basically there are about four variations of the same answer in the above linked post and I've tried each of those variations.