because I usually create a Markdown document and insert the filename as the first line of the text inside the document, I wonder if there is a way to do it automatically, and how, in order to reduce the steps needed to create the file.
This is my ideal solution:
I hit a shortcut (my present shortcut to create a new MD is CMD + Shift + M)
A new Markdown file is created
The filename is a title of my choice + the date time YYYYMMDDHHmm
The first line of the text is:
filename YYYYMMDDHHmm
I add the hashtag so that the title of the file (the first line) is a H1.
I suppose I can play with placeholders and templates, but what’s the best way to reduce the steps?
I was doing the exact same thing. My current workflow is an AppleScript that I invoke via Alfred. Here’s the script in Alfred.
on alfred_script(q)
tell application id "DNtp"
set myHome to system attribute "HOME"
set templatePath to (myHome & "/Dropbox/DevonThink/Templates/Zettlekasten Note.md")
set thisGroup to incoming group
set thisText to (q)
set theDate to do shell script "date +%Y%m%d%H%M%S"
set itemName to (thisText & " - " & theDate)
set theRecord to import templatePath name itemName placeholders {|%recordName%|:itemName} to thisGroup
try
open window for record theRecord
activate
on error error_message number error_number
display alert "Had trouble opening the created record"
return
end try
end tell
end alfred_script
This lets me invoke it with a quick keyboard shortcut for Alfred and then a Keyword configuration.
FWIW, I also use a script for creating new files from templates, invoked via a Keyboard Maestro shortcut. The use of a script is an opportunity to do additional substitutions. I also have it pop up a list of templates from which I choose the one I want in a given situation. Here it is, in case it’s useful for ideas: