What I’m trying to do
I am trying to create daily notes for all days of the current week by running a weekly note and at the same time make sure i have all other periodic notes in place like monthly quarterly and annual.
I found this topic Automatically create daily notes for the entire week by running a weekly notes template
Which was exactly what i was trying to do but it was closed and unsolved.
I figured out how to solve it and want to help others that might want to do the same.
Things I have tried
The solution that worked for me was:
<%*
// This is the function that will be called upon to create the file it it does not exist based on the name passed in the call
async function createIfNotExists(tp, filepath){ if (!(await tp.file.exists(filepath))){ app.vault.create(filepath,"") } }
// Folder locations for the periodic note need to be updated to your personal use-case
// This call can be used if you only want to add the current daily note
//await createIfNotExists(tp, "/7_Calendar/01_Daily/" + tp.date.now("YYYY/YYYY-MM-DD") + ".md")
// Create daily notes for all days of the week if you like to have a week start on monday than you need to add (+1,'weeks') otherwise you can leave that out
await createIfNotExists(tp, "/7_Calendar/01_Daily/" + moment(tp.file.title,'YYYY-[W]WW').day("monday").format("gggg-MM-DD_ddd") + ".md")
await createIfNotExists(tp, "/7_Calendar/01_Daily/" + moment(tp.file.title,'YYYY-[W]WW').day("tuesday").format("gggg-MM-DD_ddd") + ".md")
await createIfNotExists(tp, "/7_Calendar/01_Daily/" + moment(tp.file.title,'YYYY-[W]WW').day("wednesday").format("gggg-MM-DD_ddd") + ".md")
await createIfNotExists(tp, "/7_Calendar/01_Daily/" + moment(tp.file.title,'YYYY-[W]WW').day("thursday").format("gggg-MM-DD_ddd") + ".md")
await createIfNotExists(tp, "/7_Calendar/01_Daily/" + moment(tp.file.title,'YYYY-[W]WW').day("friday").format("gggg-MM-DD_ddd") + ".md")
await createIfNotExists(tp, "/7_Calendar/01_Daily/" + moment(tp.file.title,'YYYY-[W]WW').day("saturday").format("gggg-MM-DD_ddd") + ".md")
await createIfNotExists(tp, "/7_Calendar/01_Daily/" + moment(tp.file.title,'YYYY-[W]WW').day("sunday").add(+1,'weeks').format("gggg-MM-DD_ddd") + ".md")
// create the weekly note
await createIfNotExists(tp, "/7_Calendar/02_Weekly/" + tp.date.now("gggg-[W]ww") + ".md")
// create the monthly note
await createIfNotExists(tp, "/7_Calendar/03_Monthly/" + tp.date.now("YYYY-[M]MM") + ".md")
// create the quarterly note
await createIfNotExists(tp, "/7_Calendar/04_Quarterly/" + tp.date.now("YYYY-[Q]Q") + ".md")
// create the annual note
await createIfNotExists(tp, "/7_Calendar/05_Annually/" + tp.date.now("YYYY") + ".md")
%>