Dataview concatenate file path?

Hello everyone, I want to list every note inside a folder, specifically every note inside a sub-folder contained in the folder where current note is located (better see the example).

- My Daily Notes
    | - 2023
    | - 2022
    | - 2021
    - Daily Notes index.md

Inside Daily notes index.md I want to have something like this:

### 2023
Some toughts .... 
#### Notes of this year

\```dataview
LIST
WHERE contains(file.folder,this.file.folder+"\2023")
\```

###2022
Same as previous

Problem is that WHERE contains(file.folder,this.file.folder+"\2023")does not work as intended, I would just like to use current file path + subdirectory on it.

Hope the problem is clear. Thank’s.

Edit: I found a work-around, but it has a problem: it does not exclude folders, see:

WHERE contains(file.folder,join(this.file.folder,"/2023")) and 
!contains(file.folder,join(this.file.folder,"/2023/Resources")) and 
!contains(file.folder,join(this.file.folder,"/2023/Monthly Notes")) and 
file.name != "2023"

If I leave only contains(file.folder,join(this.file.folder,"/2023")) it works, but if I add the other 2 filters it does not display any note.

Edit2: ok I was wrong, neither contains(file.folder,join(this.file.folder,"/2023")) works as intended, so I’m back to start.

Instead of using contains(), I’d rather use the startswith(), function, so try variations over: startswith(file.folder, this.file.folder + "/2023")

If that doesn’t work I would switch to using TABLE file.folder, this.file.folder possibly with the various constraints instead of LIST just to verify what you’re comparing in the various cases.

WHERE startswith(file.folder, this.file.folder + "/2023") and 
!startswith(file.folder, this.file.folder + "/2023/Monthly Notes") and
 !startswith(file.folder, this.file.folder + "/2023/Resources") and 
file.name != "2023"

Worked perfectly! Will never fully understand dataview… This was completely absent from documentation. Anyway, good it works, thank’s very much

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