Bases: Parent folder of parent folder of a file

What I’m trying to do

I’m trying to create a link to the folder note in the parent folder of a file’s parent folder:

given: Photography/Scrapbook/ScrapData/Portraits/assets/foo.jpg

I need [Portraits](Photography/Scrapbook/ScrapData/Portraits/Portraits.md)

Things I have tried

formulas:
  Parts: file.folder.replace("assets", "" ).split("/" )
  Name: formula.Parts[formula.Parts.length-2]
  Path: formula.Parts.join( "/" ) + formula.name
  Photographer: link(formula.Path, formula.Name )

Which works but it feels a bit kludgy and probably not very robust. Is there a better way to traverse back up the tree?

If the note is always named Portraits.md, then how do you like:

link(file.folder.split("/").slice(0,-1).join("/") + "/Portraits.md").asFile()

But if the name of the grandparent folder and note can vary (e.g., Photography/Scrapbook/ScrapData/Lorem/Lorem.md), then:

link((file.folder.split("/").slice(0,-1) + file.folder.split("/").slice(-2,-1)).join("/")).asFile()

Thanks, but I was hoping there might be a way of doing it more robustly and more legibly through access to file and folder objects. As in file.parent.parent kind of thing.

Are you asking if there’s a built-in function for that? There isn’t. (Bases functions.) Not currently anyway.

Or are you trying to make a feature request?