How to get a list of linked notes but only showing a part of their file name?

What I’m trying to do

Situation

I use templates to create

  • 1 “master note”
  • n related “sub notes”
  • links to each sub-note from the master note

The sub-notes are automatically named based on the master note’s name.
E.g.:
master note: “I am the boss”
sub notes:
“I am the boss - you wish”
“I am the boss - keep dreaming”

Challenge

I want to add a dataview query that returns

  • a list (or table) of all sub-notes to which the master note links, BUT
  • only showing the part of the sub-note’s name after the delimiter " - "

I manage the first part fine, but showing only the partial file name of the sub-notes beats me.

Thank you.

Things I have tried

I went through the dataview documentation, tried snippets - even almighty ChatGPT - alas, to no avail.

Try using eithersplit() or possibly regexreplace() to remove the unwanted parts. Either should work with slightly different pros and cons.

I tried - and failed. My current dataview code:

LIST FROM "01 👻 Projects/🎞️ LP Videos"
WHERE contains(file.name, ("<% tp.file.title.split(' - ')[0] %>"))
	AND file.name != "<% tp.file.title %>"
SORT file.name ASC

resulting in
image

and i would like to have only the part of the note title inside the red rectangle.

Does that query return the correct files?

If so try to replace LIST with the following:

LIST WITHOUT ID link(file.link, "<% tp.file.title.split(' - ')[1] %>"

Untested, but it might work… :slight_smile:

You could also try file.name if file.link fails (… or possibly file.path)

Thank you. Yes, the query i shared works and delivers the result in the picture. i.e., the full file name.

adding your suggested code, gives me this:
image

I’m kind of surprised why your split is not working, as it does work in my case. So here are two queries two further explore your case:

```dataview
TABLE split(file.name, " - "), file.name
WHERE startswith(file.name, this.file.name)
```

```dataview
LIST WITHOUT ID link(file.link, split(file.name, " - ")[1])
WHERE startswith(file.name, this.file.name)
  AND contains(this.file.outlinks, file.link)
```

In my simple test setup with three sub notes, where only the two first are linked from the master note, this results in the following output:

You are my hero :slight_smile:

Your code works, if I put it in the master file - but not in the subs. However, you pointed me in the right direction and I found this solution:

LIST WITHOUT ID link(file.link, split(file.name, " - ")[1])
FROM "01 👻 Projects/🎞️ LP Videos"
WHERE startswith(file.name, split(this.file.name, " - ")[0])

Giving me the desired result:
image

thank you so much, friend.

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