Yearly template

Is there a particular reason for using the app.vault.create() function? I found that if I used the tp.file.create_new() function, I could get it to create paths for me on the go.

So if you want your script to generate the review file on a path, possibly not defined, underneath the /Journal folder of your vault, you could do:

await tp.file.create_new(
          content, `${year}/${year}`, false

This works how ever many levels deep you want to go. It does require something sensible as the base folder, but using “/” would allow for you to create files all over your vault.

No particular reason. I used that function for something previously and never thought to look for an alternate method for making a new note.

In this case I was not particularly worried that the folders existed, since the expected folder hierarchy was already established for the daily notes.

So I made the changes you suggested, and here’s the current code block in the daily template file:

if ('MM-DD') == '01-12')
   const year = parseInt('YYYY'));
   const review = `/Journal/${year}/${year}`;
   if (!tp.file.exists(review))
      const content = `---
creation-date: ${"dddd Do MMMM YYYY HH:mm:ss")}
modification-date: ${"dddd Do MMMM YYYY HH:mm:ss")}

<< [[${year - 1}-Review]] | [[${year + 1}-Review]] >>


# Goodbye ${year}

# Hello ${year + 1}
      await app.vault.create(review,content);

I’ve also tried turning on file extensions, as well as checked the obsidian folder on iclouddrive in Obsidian/Notes/Journal/2023, and it only contains the folder Jan no 2023-Review file. Yet when I select today from the cal to make the daily note, it only makes a daily note, not a 2023-Review note.

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