How can I add random notes to my daily note while ignoring some folders?

Do you mean something like the following?

<%*
const noOfNotes = 5
const dv = this.DataviewAPI
const files = await dv.tryQuery(`
  LIST
  FROM -"_tools/template" AND -"Presentations/Export"
`)

let randomList = []

for (let i = 0; i < noOfNotes; i++) {
  const random = Math.floor(Math.random() *
                            (files.values.length - 1))
  randomList.push(files.values[random])
}

tR += dv.markdownList(randomList)
%>

The query at the top could be written differently, but I made it this way so that if you want you can play around with the query, and modify to give you the list of notes you want to be included in the random notes list.

In other words, try out the following query on some page:

```dataview
  LIST
  FROM -"_tools/template" AND -"Presentations/Export"
```

The result of this query will be all the notes that your randomiser will pick from. If you don’t like it, modify the query, and get it to show the files you want, then insert that query into the template above.

3 Likes