QUICKADD to a subfolder of the folder of the current note

What I’m trying to do

Use the QUICKADD plugin to create a new note in a subfolder of the folder containing the current note.

Things I have tried

Using a “Capture” type add-method, but I cannot find a variable containing the currentlink’s path

SOLVED MY OWN PROBLEM:
I don’t think you can use quick add since you cannot variablize the folder structure. Instead I used Templater and scripted it to create sub folders.
The following code is placed inside an empty template and then triggered to create the folder.

  • Prompt is getting input,
  • createFolder is creating a new folder using an absolute path, while
  • create_new is using a path relative to the current note.
  • cursor_append is adding a link inside the existing note.
    It is a bit hacky but it got my job done.

To use, add this code to an empty template:

<%-*
const title = await tp.system.prompt(“SUB Folder Note”);
const dir = require(“path”).dirname(tp.file.path(true)) + “/” + title;
await this.app.vault.createFolder(dir);
await tp.file.create_new(“”, title + “/” + title + “.md”, false);
tp.file.cursor_append(“[[” + title + "]] ");
-%>

1 Like