How to automate creating of periodic notes?

This might not be an Obsidian-problem as such, but… I’m having a problem with my workflow. I have daily periodic notes, that are created using Templater template. But when I try to create the daily note for next day at the end of the day, I get an templater error saying “Template parsing error, aborting. Destination file already exists!”. I think this might be because the template has entries that refer to this day, like “”, and I feel it gets confused because I’m trying to create it on a different date.

But instead of trying to work around this problem, I started thinking: Would it be possible to somehow automate the creation of this file? Like, every day at 1am the note is created in the vault. This would also have the benefit that the file is already there waiting in the morning. Creating the file when on mobile could be a bit of a hassle.

I have a server that is running 24/7 that could be used for this. And the file itself could be created outside Obsidian. So basically I would need some kind of system that creates the file and places it in my vault. Which should be doable as the vault is just a bunch of files and folders. The tricky thing is that there is some dynamic stuff that needs to be in the file. Name of the file would be in YYYY-MM-DD format, and there would be couple of references to current date, as well as yesterday and tomorrow (and maybe number of the week as well).

So how could this be done? I’m on Mac, so I could look in to using Shortcuts, Keyboard Maestro and the like.

You probably want to investigate writing a script and configuring it to run using launchd on your Mac. This script could create the file automatically for you. If you simply want a completely blank file with the appropriate name, your shell script could be as basic as

touch /path/to/wherever/you/want/the/file/`date "+%Y-%m-%d"`.md

If you want more complex data in there, you can possibly get by using a bunch of echo commands, but that might become unwieldy. :confused:

Actually, it might be possible to simply alter your template so that it works as expected for arbitrary dates. - Templater suggests that you can provide a “referential” for the date – for example, setting it to the note’s title.

There are examples on that page which might work for you – it could be as simple as making sure that all your calls to include the file’s name as a reference.

The Calendar plugin lets you click any day in the calendar to create a note using the daily note template. I don’t know if it works with Templater.


That’s what I’m doing. I click on the date to create the new periodic note, and I get an templater error. It does create the file, but all the dynamic templater things are there as raw code.

This would be the easiest way. At the end of the day I create tomorrow periodic note. But it’s not working. If I create the note with Templaters “Create new note from template” it works fine. And if I create todays note from the calendar, that works fine as well.

There are couple of dynamic things in the note:

  1. The name of the note: YYYY-MM-DD
  2. Links at the top of the note, pointing to yesterday and tomorrow, shown in YYYY-MM-DD format
  3. Date-field in the note itself: YYYY-MM-DD
  4. Entry for the week: YYYY-[W]ww

So I basically need a way to pass that info to the note at the time of creation. I think 1 and 2 should be doable, 4 is optional, I can enter it manually if needed. 2 might be tricky, as I basically need to pass something like “YYYY-MM-DD -1” and “YYYY-MM-DD +1” to the note.

This can all be achieved using the file name as the reference date (or similar) instead of using So your template check for the file name and set date stuff related to that.

Exactly how you need to change your template is hared to tell since you’ve not shown us any of your template.

If these are the only things you use Templater for in your daily note template, another option is to use the Periodic Notes plugin instead of Daily Notes and Templater. It offers date-math template tags and works with Calendar to create not-today daily notes.

I have written a quite complicated shortcuts script which pulls a lot of health data and all kinds of stuff and then creates my daily note with all that data. I am using the wonderful “Actions for Obsidian” by Carlo Zottmann to suplement the existing Shortcuts options. And then I use the automation on my iPhone to trigger the daily not creation when my alarm goes in the morning. On weekends with no alarm, I run it manually when I wake. The reason I wait till I am awake, is that it grabs my sleep data from Health also.

1 Like

I am using Periodic Notes for this.

Oh, and the relevant part of the template is like this:

### |<<[[<"YYYY-MM-DD", -1) %>]] | | [[<%"YYYY-MM-DD", 1) %>]]>>| 

## Date: <"YYYY-MM-DD")%>
## Week:: [[<"YYYY-[W]ww")%>]]

I think that is not playing nice with Periodic Notes, if I try to create the daily note for different date than today.

OK, I think I figured this out. At the bottom of my template, I had this:

<% await tp.file.move (“/Tracking” + “/” + “1 Daily” + “/” +“YYYY-MM-DD”)) %>

That caused the issue of periodic note not working. It was at the very bottom, so I missed it.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.