I misread parts of your request, and file.folder
is not available in your current context. What’s available is file.parent.path
, and that is the folder of the current file. Some further testing indicates that there is a slight difference when handling the root folder as the file.parent.path
then becomes /
, but the dv.current().file.folder
becomes empty.
With that taken into account try this one to list all files in the current directory:
```dataviewjs
let parentFolder = dv.current().file.folder
if (parentFolder == "")
parentFolder = "/"
const lsFolder = app.vault.getFiles()
.filter(file => file.parent.path == parentFolder )
.map(file => dv.fileLink(file.path))
dv.list(lsFolder)
```