Saving to Markdown (*.md) rather than txt (*.txt)

I’ve created an action to save the content as a markdown file with the .md extension. That works well in the first phase, but when the Mac O/S file dialog pops up to save the file, .txt has been appended to the file name:



I’ve tried a couple of different variations on the code, but nothing seems to work:

// clean file name
function cleanTitle(title) {
	var clean = title.toLowerCase();
	clean = clean.replace(/[^a-z0-9_\s]/g, '');
	clean = clean.replace(/\s+/g, '-');
	return clean;

// prompt for file name
var title = cleanTitle(draft.processTemplate("[[safe_title]]"));

var title_ext = title + ".md";

var p = Prompt.create();
p.title = "Save as...";
p.addTextField("fileName", "Name", title);

if ( {
   var fileName = p.fieldValues["fileName"];
   draft.setTemplateTag("file", fileName);
else {

Looks like your script is just passing some template tags onto a file saving step. You should use a “File” step to set the extension (my guess is that you are currently using either the Export step, or a File step with a .txt extension set).