Despite of this question covers Windows CMD, AutoHotkey and MultiMarkdown, I believe, the problem is closely related to CMD (my lack of knowledge of Windows bat files).
So...
I'm trying to create AHK-script for MultiMarkdown, which will allow to convert mmd files to any extension (not particulary html).
This is how I could do it with plain bat file:
chcp 65001
set ext=mmd2html
for %%i in (*.md) do call multimarkdown --escaped-line-breaks --process-html --nosmart "%%i" > %%~ni.%ext%
This works. If you place this bat file together with your mmd-files, it will properly convert and rename them.
However, when I'm trying to place this code into AHK script, it fails. Here is what I have:
#SingleInstance, Force
f1::
bat_script =
(join&
chcp 65001
set ext=mmd2html
for `%i in (*.md) do call multimarkdown --escaped-line-breaks --process-html --nosmart "`%i" > `%~ni.`%ext`%
)
Run, %ComSpec% /c %bat_script%, %A_ScriptDir%
return
How it can be solved?
Post updated
The actual problem is that instead of renaming files like this:
my_test_file.md --> my_test_file.mmd2html (yes, "mmd2html" is an extension)
it renames literally:
my_test_file.md --> my_test_file.%ext%
In other words, the script doesn't understand that %ext%
is variable. Here is working AHK code, without using var:
f1::
bat_script =
(join&
chcp 65001
for `%i in (*.md) do call multimarkdown --escaped-line-breaks --process-html --nosmart "`%i" > `%~ni.aaaaaaaa
)
Run, %ComSpec% /c %bat_script%, %A_ScriptDir%
return
However, I want to use variable for file extension, so this working code posted here just for demonstration purposes.