<p>I'm writing some documentation in Markdown, and creating a separate file for each section of the doc.  I would like to be able to convert all the files to HTML in one go, but I can't find anyone else who has tried the same thing.  I'm on a Mac, so I would think a simple bash script should be able to handle it, but I've never done anything in bash and haven't had any luck.  It seems like it should be simple to write something so I could just run:</p>

<pre><code>markdown-batch ./*.markdown
</code></pre>

<p>Any ideas?</p>

[{'answer_id': 18775, 'author': 'Julio César', 'author_id': 2148, 'author_profile': 'https://Stackoverflow.com/users/2148', 'pm_score': -1, 'selected': False, 'text': '<p>I use this in a .bat file:</p>\n\n<pre><code>@echo off\nfor %i in (*.txt) python markdown.py "%i"\n</code></pre>\n'}, {'answer_id': 18831, 'author': 'Patrick McElhaney', 'author_id': 437, 'author_profile': 'https://Stackoverflow.com/users/437', 'pm_score': 6, 'selected': True, 'text': '<p>This is how you would do it in Bash.  </p>\n\n<pre><code>for i in ./*.markdown; do perl markdown.pl --html4tags $i &gt; $i.html; done;\n</code></pre>\n\n<p>Of course, you need the <a href="http://daringfireball.net/projects/markdown/" rel="noreferrer">Markdown script</a>.</p>\n'}, {'answer_id': 18841, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 6, 'selected': False, 'text': '<p>Use <a href="https://github.com/jgm/pandoc" rel="noreferrer">pandoc</a> — it\'s a commandline tool that lets you convert from one format to another. This tool supports Markdown to HTML and back.</p>\n\n<p>E.g. to generate HTML from Markdown, run:</p>\n\n<pre><code>pandoc -f markdown index.md &gt; index.html\n</code></pre>\n'}, {'answer_id': 40245401, 'author': 'Bruce Zu', 'author_id': 913717, 'author_profile': 'https://Stackoverflow.com/users/913717', 'pm_score': -1, 'selected': False, 'text': '<p>// using Bash in mac</p>\n\n<pre><code>for i in *.md; do asciidoc  $i;  done; \n</code></pre>\n'}, {'answer_id': 70998307, 'author': 'np8', 'author_id': 3015186, 'author_profile': 'https://Stackoverflow.com/users/3015186', 'pm_score': 0, 'selected': False, 'text': '<p>You can do this really easily with <strong><a href="https://code.visualstudio.com/" rel="nofollow noreferrer">VS Code</a></strong>. <em>(Well, this is not a command line tool, but proved itself to be super helpful.)</em></p>\n<ul>\n<li>Install the <a href="https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one" rel="nofollow noreferrer">Markdown All In One</a> extension by Yu Zhang</li>\n<li>Open the VS Code Command Palette (<code>Ctrl-Shift-P</code>), and select <code>Markdown All In One: Print documents to HTML (select a source folder)</code></li>\n<li><strong>Tip</strong>: If you want to make your export portable, you want to change absolute image paths to relative paths by using the following setting in your <code>settings.json</code> (<code>Ctrl-Shift-P</code> -&gt; <code>Preferences: Open Settings (JSON)</code>)</li>\n</ul>\n<pre><code>    &quot;markdown.extension.print.absoluteImgPath&quot;: false\n</code></pre>\n<p>In this way, after conversion, just copy all non-markdown files (images) to the destination folder and the HTML pages are portable.</p>\n'}, {'answer_id': 73435178, 'author': 'injashkin', 'author_id': 19661777, 'author_profile': 'https://Stackoverflow.com/users/19661777', 'pm_score': 1, 'selected': False, 'text': '<p>If you have Node.js installed, then you can use the [MdPugToHtml] converter (<a href="https://www.npmjs.com/package/md-pug-to-html" rel="nofollow noreferrer">https://www.npmjs.com/package/md-pug-to-html</a>). It massively converts Markdown to Html. Moreover, it is possible to use Pug templates, but you can use them without templates.</p>\n<p>The conversion is performed in the terminal with just one command:</p>\n<pre><code>npx md-pug-to-html /home/content\n</code></pre>\n<p>where:</p>\n<ul>\n<li><code>npx</code> is an npm command that installs md-pug-to-html at the first launch, and then launches the md-pug-to-html converter.</li>\n<li><code>/home/content</code> is a directory with your Markdown files. You may have another one.</li>\n</ul>\n<p>The converter has various settings and can be used both in the CLI command line and has an API for use in applications.</p>\n<p>There is detailed documentation on the MdPugToHtml converter in <a href="https://github.com/injashkin/md-pug-to-html/blob/main/README.md" rel="nofollow noreferrer">English</a> and <a href="https://github.com/injashkin/md-pug-to-html/blob/main/README.ru.md" rel="nofollow noreferrer">Russian</a>.</p>\n'}]
['https://Stackoverflow.com/questions/18754', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2185/']