hey, can you write me an obsidian templater script to create and open daily periodic…
- User
hey, can you write me an obsidian templater script to create and open daily periodic notes using templater and periodic notes plugin?
- Assistant
Sure! To create a script for creating and opening daily periodic notes in Obsidian using the Templater and Periodic Notes plugins, follow these steps:
-
Install the Templater and Periodic Notes Plugins:
- Open Obsidian.
- Go to
Settings->Community Plugins->Browse. - Search for "Templater" and click "Install," then click "Enable."
- Search for "Periodic Notes" and click "Install," then click "Enable."
-
Set Up Periodic Notes:
- Go to
Settings->Periodic Notes. - Configure the settings for "Daily Notes" as desired (e.g., date format, folder location, template file location).
- Go to
-
Create a Daily Note Template:
- Create a new file in your templates folder (e.g.,
Templates/Daily Note Template.md). - Add any placeholders you want to use (e.g.,
{{date}},{{time}}, etc.).
- Create a new file in your templates folder (e.g.,
-
Create the Templater Script:
- Create a new file (e.g.,
Scripts/Open Daily Note Script.md).
- Create a new file (e.g.,
Here's an example of the Templater script to create and open the daily note:
markdown<%* const moment = tp.date.now("YYYY-MM-DD"); // Define the path for the daily note based on the current date const dailyNotePath = `Daily Notes/${moment}.md`; // Check if the daily note already exists const fileExists = await app.vault.adapter.exists(dailyNotePath); if (!fileExists) { // Create the daily note using the preset template const templateContent = await tp.file.read("Templates/Daily Note Template"); const filledTemplate = await tp.templates.parse_template(templateContent, {date: moment}); await app.vault.create(dailyNotePath, filledTemplate); } // Open the daily note const dailyNoteFile = app.vault.getAbstractFileByPath(dailyNotePath); await app.workspace.getLeaf().openFile(dailyNoteFile); %> -
- User
i forgot to say, i want it to run as soon as obsidian starts, so it automatically creates and open my daily note i already have both plugins downloades, and folders created, i just need the script
- Assistant
- User
it didnt work, i changed the name of the note to Template Startup, my periodic notes are Jounal/Daily in templater startup i put the note for it to read it
- Assistant