How to find out all files in current folder with Bases?

What I’m trying to do

I have every project in a different folder.
For every project I created a MoC file named “moc Any project title”.
In this moc file I want to use a base to show me all the files different to this moc file in it’s current folder.

Things I have tried

I looked for a function to grep the path. Couldn’t find.

I tried this to find out if “.” is the current directory:

views:
  - type: table
    name: Table
    filters:
      and:
        - file.inFolder(".")

it’s not.

Under dataview it would be:

LIST
WHERE contains(file.folder,this.file.folder) AND file.name != this.file.name

Any solution for it?

You could try a filter of

file.inFolder(this.file.folder) && file.path != this.file.path

in an embedded base or a base code block in a note.

file.inFolder(this.file.folder) returns all the files (and files in sub-folders) in the same folder as the note.

&& file.path != this.file.path removes the host note itself from the list; this is optional or can be separated into its own filter.


I embed this .base#view in all my “folder notes” to get a dynamic list of what’s in the folder. It’s been working out well so far.

4 Likes

Thank you very much!

I modified it to my preferences: The following does not include subfolders and only shows md files:

file.folder == this.file.folder && file.ext == “md” though && file.path != this.file.path

1 Like

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