Templater plugin Showcase

Please share your Templater plugin templates or Snippets here for all to see…

1 Like

This Templater snippet was largely written by fellow forum member @shabegom. Thank you, Shabegom.

The purpose of the snippet is to move yesterday’s Daily Note to a storage folder (PAST) when Obsidian starts up each day. It was becoming a nuisance to move the old daily notes to storage.

This could be made to work, with minor code changes, for any recurring note that you want to move to some other folder.

You wouldn’t know unless you looked at the settings, but Templater was recently updated and the latest version allows you to create a separate template with code snippets only which then run on Obsidian startup. Exactly like a startup script.

So I took the below “move/rename old notes to storage” snippet out of my daily note template and put it in a separately named template, and then pointed Templater to that new startup template. This way my Daily Note stays clean and doesn’t have empty ```s left over after the snippet runs.

Basically, Templater is becoming Obsidian Scripting. Its very cool, I open Obsidian, I see yesterday’s note disappear(renamed/moved to PAST folder) and today’s daily note pops into existence in the same place.

Only caveat, is that you have to use the full path within your Vault, so I have a “001 DAILY” folder where my Daily Notes are created, and within that folder I have another storage folder called PAST. Please change the path to your particular situation or you will receive an error.

Also, I am moving/renaming a note with a Date for a note title - you can see that in the first two lines. Your situation will be different if your Daily Notes use a different title name or date format.

The script only moves yesterday’s daily note, it doesn’t look for older dates. This is only an issue when you open Obsidian after not using it for a weekend say. You might have to move a few notes to storage to get back on track.

If someone wants to enhance the script, please feel free and post your working results here.

```
<%*
const date = tp.date.now(“YYYY-MM-DD”,-1)
const file = tp.file.find_tfile(date)

if (file) {
const name = file.basename
await app.fileManager.renameFile(file, `001 DAILY/PAST/${name}.md`)
}
%>
```

1 Like