I wanted to set the default title of new notes created via Cmd+N to be formatted like "2023-05-18 New", "2023-05-18 New 2", ...
I also wanted all new notes created via Cmd+N to go in the new
folder.
-
Create a folder called e.g.
new
-
In "Files & Links" settings, set "Folder to create new notes in" to
new
-
Create a folder called e.g.
templates
and add a file called e.g.Default
with this content:
<%*
for (let i = 1; i < 20; i++) {
let suffix = i == 1 ? '' : ` ${i}`;
// Replace with whatever format you want for your default note title
let filename = `${tp.date.now("YYYY-MM-DD")} New${suffix}`;
try {
await tp.file.rename(filename);
return;
}
catch (e) { // assume file already exists, try next filename
}
}
-%>
-
Install the Templater community plugin
-
In Templater settings:
- Set a templates folder location e.g.
templates
- Enable "Trigger Templater on new file creation"
- Enable "Enable Folder Templates"
- Add a new folder template for the folder
new
mapping totemplates/Default.md
That's it! When you press Cmd+N, a new note will be created in the new
folder with the filename pattern specified in the template code.
Thanks for the guide. This is precisely what I wanted as well.