Good way to quickly create date-stamped note in "Meetings" folder, for any date?

I create date-stamped notes for meetings like “Work/Meetings/2024-02-08 Sprint planning”.

I have a QuickAdd macro to add a meeting for today’s date, which works fine. I hit cmd+p, find “QuickAdd: Meeting”, it prompts me for a title (e.g. “Sprint planning”) and creates the document.

But I often create notes for future meetings – in the next sprint planning, I want to remember to bring this up.

I tried making another QuickAdd macro with the file name format {{VDATE:Date, YYYY-MM-DD}} {{name}} and it works, but it’s not great. It prompts for the name before the date which feels wrong, and the date prompt is just a text field – some kind of date picker would be more useful. (I know it supports natural language date formats.)

I guess my ideal is something like Daily Notes with the Calendar plugin. Any ideas?

I don’t want to use Daily Notes for this – I do use them, but for other purposes.

I could perhaps cobble something together from https://www.reddit.com/r/ObsidianMD/comments/ocylcf/how_to_auto_name_a_notefile_when_a_specific/ and I created the date picker with the Templater plugin, but I’m hoping for something a bit more ready-made :crossed_fingers:

I gave Templater a shot and did cobble something together. This is a first, unpolished stab, but it seems to work.

I installed the Templater plugin and added a file in its directory with the following contents.

The date picker is from I created the date picker with the Templater plugin - #5 by JRyven.

<%*
const template = tp.file.find_tfile("Meeting");
const folder = app.vault.getAbstractFileByPath("Work/Meetings");

const suggestions = new Map()
suggestions.set(
  "Today, "+moment().format('ddd MMM, D'),
  moment()
)
suggestions.set(
  "Tomorrow, "+moment().add(1,'days').format('ddd MMM, D'),
  moment().add(1,'days')
)
suggestions.set(
  moment().add(2,'days').format('ddd MMM, D'),
  moment().add(2,'days')
)
suggestions.set(
  moment().add(3,'days').format('ddd MMM, D'),
  moment().add(3,'days')
)
suggestions.set(
  moment().add(4,'days').format('ddd MMM, D'),
  moment().add(4,'days')
)
suggestions.set(
  moment().add(5,'days').format('ddd MMM, D'),
  moment().add(5,'days')
)
suggestions.set(
  "Manual",
  null
)

const selection = await tp.system.suggester(
    [...suggestions].map(([k, v]) => k !== "Manual" ? k + " (" + v.format("YYYY-MM-DD") + ")" : k),
    Array.from(suggestions.values())
)

let fileDate = null
if (!selection) {
    inputDate = await tp.system.prompt("Type a date (DD MM? YY?):")
    fileDate = moment(inputDate, "DD MM YY")
    if (!fileDate.isValid()) {
      fileDate = moment()
    }
} else {
    fileDate = selection
}

const formattedFileDate = fileDate.format("YYYY-MM-DD");

const throwOnCancel = true;
const meetingName = await tp.system.prompt("Meeting name?", "", throwOnCancel);

const filename = `${formattedFileDate} ${meetingName}`;

const openOnCreate = true;
await tp.file.create_new(template, filename, openOnCreate, folder);
%>

Now, I can trigger this template via Templater (I will look for a way to get it as a top-level entry in the cmd+p command picker), it prompts for the date, then prompts for the name, then creates and opens the file.

Among other things I’d like to improve/investigate, I feel uncomfortable with

const template = tp.file.find_tfile("Meeting");

finding my “Meeting” template from my templates (not Templater) folder by just its name.

I want to repeat this is a first, super-unpolished stab.

Cleaned up version.

This one no longer uses an external template file – it just uses the non-code content in the template file itself.

I’m using the Templater “Template Hotkeys” setting to trigger this more easily.

I tried using tp.file.move instead but ended up moving the template file itself, so create_new it is.

## Participants

## Discussion

## Actions

<%*
const folder = app.vault.getAbstractFileByPath('Work/Meetings');

const suggestionTexts = [];
const suggestionValues = [];

const addSuggestion = (addDays, suffix = '') => {
  const text = moment().add(addDays, 'days').format('YYYY-MM-DD (ddd)') + (suffix ? ` – ${suffix}` : "");
  const value = moment().add(addDays, 'days');

  suggestionTexts.push(text);
  suggestionValues.push(value);
}

addSuggestion(0, 'Today');
addSuggestion(1, 'Tomorrow');
addSuggestion(2);
addSuggestion(3);
addSuggestion(4);
addSuggestion(5);
addSuggestion(6);
addSuggestion(7, 'Same day next week');

suggestionTexts.push('Manual');
suggestionValues.push(null);

let date = await tp.system.suggester(suggestionTexts, suggestionValues);

if (!date) {
    inputDate = await tp.system.prompt('Date (DD MM? YY?):');
    date = moment(inputDate, 'DD MM YY');

    if (!date.isValid()) {
      date = moment();
    }
}

const dateString = date.format('YYYY-MM-DD');

const throwOnCancel = true;
const meetingName = await tp.system.prompt('Meeting name', '', throwOnCancel);

const filename = `${dateString} ${meetingName}`;

const openOnCreate = true;
await tp.file.create_new('', filename, openOnCreate, folder);
%>
2 Likes

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