How to create an automatic list of all CANVAS?

What I’m trying to do

I’m trying to create a note in which automatically get listed all the CANVAS I’ve created.
Maybe with Dataview or any other plugin…

Things I have tried

An attempt with dataview, but I was not successfull

1 Like

Here is a simple script which lists all canvases:

```dataviewjs
let c = Object.entries(dv.app.metadataCache.fileCache)
   .filter( ([name, stats]) => name.endsWith(".canvas") )
   .map( ([name, stats]) => {
     const matches = name.match(/([^/]+)\.canvas$/)
     return dv.fileLink(name, false, (matches ? matches[1] : name))
   })

dv.list(dv.array(c).sort(l => l.display, 'desc'))
```

Update: I added a simple removal of the path and file extension, and a simple sort to make the list look a little more presentable.

5 Likes

Another way is to embed a query with proper backticks (not sure how to embed this in this post)

```query
file:.canvas
```
4 Likes

Use four backticks around code blocks to be included in forum posts, like:

```query
file:.canvas
```

Or if you want to demo how the 4 backticks would look, you can use 5 backticks :grin:

````
```query
file:.canvas
```
````

:ocean:

~~~~
```query
file:.canvas
```
~~~~

many thanks for the tick tips … and the chuckles!

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