This setup will let you choose a file from a folder you specify, then open up the Tasks modal to input your task parameters.
- Open a text editor and paste the following in there (removing the backticks):
module.exports = async function listFiles(params) {
const fileType = {
folder: "",
folderExclude: "",
fileExclude: ""
}
const files = params.app.vault.getMarkdownFiles()
.filter(file => file.path.match(fileType.folder))
.filter(file => {
if (fileType.folderExclude) { return !file.path.match(fileType.folderExclude) }
else { return file }
})
.filter(file => {
if (fileType.fileExclude) { return !file.path.match(fileType.fileExclude) }
else { return file }
})
const notesDisplay = await params.quickAddApi.suggester(
(files) => files.basename, files
);
if (!notesDisplay) {
new Notice("No file selected.");
throw new Error("No file selected.");
}
params.variables = {
note: notesDisplay.path
};
}
- Set the variables
folder
,folderExclude
andfileExclude
to whatever you need, where:folder
is the folder you want to includefolderExclude
is a folder you want to excludefileExclude
could be a file name pattern you want to exclude
- Save the file in your vault as
capture-task.js
, making sure that the file extension isjs
(and not.js.txt
)! - Open the QuickAdd settings and add a macro choice via the “Add choice” button.
- Open the configuration screen of the macro choice, then first click on the plus button and then the cog symbol that remains.
- Select
capture-task
in the “User Scripts” dropdown & add it. - Add your capture from the “Choices” dropdown.
- Go back to the main QuickAdd settings and configure your Capture so that the file name is set to
{{VALUE:note}}
, leave the rest.