Quickly jump to periodic file in Obsidian

| 3 min read

I'm currently working with a client to unstuck a team blocked by a legacy codebase and complicated work processes. I send a weekly report of things we've done and things I think we should work on to make help us move forward to a few people in the company.

I'm using Obsidian as my note-taking application, trying to build some sort of a second brain, and I, of course, write my reports there, to keep track of them.

Working with reports was a bit annoying because as I have a report per week, I have a new file name every week made from the date of my last day working with a client, and I had trouble quickly accessing it to add new information. I could use the week number for the filename, but I'm the kind of person who keeps track of time in weeks, which means I never know what the current week is.

I wanted to find a way to open the current week's report quickly, and I did an experiment using Templater, an Obsidian plugin, and it works. Even better, the first time I access the weekly report and it doesn't exist yet a new report is created in the correct directory with my basic weekly report template.

I know that other plugins help to manage recurrent notes, such as Periodic Notes. Still, I'm already using the weekly periodic note system for something else, and it would lose all the fun of the experiment.

The template

The idea is to use a Templater template, which comes with a few interesting functions, to make everything work. When I'm somewhere in the application, I can use a shortcut to introduce the template, the template is processed, and the logic is executed. In case the report doesn't exist, it creates it, and in any case, takes me to it.

Here is the template with some comments

<%*
// Generate the file name. I'm not working on Friday's with that client
// so I end my week on Thursdays => start of week + 3 days
const fileName = moment()
.startOf('Week')
.add(3, 'd')
.format('[W]WW-YYYY-MM-DD');

// Where Weekly reports are stored
const weeklyReportDirectory = '/🦺 Projects/MY-CLIENT/Weekly reports/';
const fullFileName = weeklyReportDirectory + fileName;

// Try to access the file
const file = tp.file.find_tfile(fileName)

if(file !== null) {
// The file exists, open it
return await app.workspace.getLeaf(false).openFile(file);
}

// The file doesn't exist
// Get the report template
const template = tp.file.
find_tfile('/🦺 Projects/MY-CLIENT/Templates/Weekly Report.md');
// Create a new file based on the template
const newReport = await tp.file.create_new(template, fileName, true);
// Move that newly created file to the report directory
await tp.file.move(fullFileName, newReport)
%>

Making it work from everywhere

Unfortunately, Obsidian's template system can't append a template when no file is opened. This is clearly a minor issue as I have almost always one file opened, but I wanted to access the report quickly in any situation. Also, even if the solution is based on a template, using the template shortcut to select a template to go to another file felt weird. In my opinion, it would be better to have that quick access right in the Obsidian main action menu.

The solution to my problem is to use the QuickAdd plugin.
With QuickAdd, you can capture elements to a page, format these elements using a template, and run the capture macro from the main menu.

Here is the recipe:

  • In QuickAdd, create a capture macro
  • Select Capture to active file
  • Select Capture format
  • Copy-Paste the template created before in the text area
  • In Quick Add main menu, click the lightning strike icon to add a command to the main menu

Now, I'm able to open the Obsidian main action menu, select the Quick Add command and access the weekly report.

I don't need to think about the date and try to guess the filename to access my weekly reports. A little brain power saved each time!