First, create a snippet in the snippets
folder named list_files_in_folder.js
. This snippet is only needed to be created once, as it is configurable and will be the base for all the other steps.
module.exports = {
entry: async (QuickAdd, settings) => {
const folderName = settings.folderName;
const files = await QuickAdd.app.vault.getFiles();
const { quickAddApi: { suggester } } = QuickAdd;
const filteredFiles = files.filter(file => file.path.includes(folderName));
const pickedFile = await suggester(
(file) => file.basename,
filteredFiles
);
QuickAdd.variables.pickedFileName = pickedFile.basename;
QuickAdd.variables.pickedFilePath = pickedFile.path;
},
settings: {
name: "File picker",
author: "Danielo Rodriguez",
options: {
folderName: {
type: "text",
defaultValue: "",
placeholder: "Folder name",
},
}
},
};
Then you need to create a new macro and a new macro choice for each use case. This is a bit tedious and I don't know why this indirection is needed.
In this example, I will be creating one macro choice for visiting restaurants (called Macro - Visit restaurant
) and another one for interacting with people/taking notes about someone, called Macro - Person note
. As I mentioned, we also need a new macro for each of those so we can properly configure the script.
In the following screenshots, you will see the visit restaurant already created and I'm going to create the person note one:
Now let's add the macro choice that makes use of this macro:
Click Add choice
, then click in the cog icon and select the new macro list-files-person