How can i display a listing of files in a folder that contain a specific string?

const pdfFiles = app.vault.getFiles().filter(file => file.extension === 'pdf' && file.path.includes('Rechnungen'))
dv.list(pdfFiles.map(file => dv.fileLink(file.path)))

how can i display a listing of files in a folder that contain a specific string?

I have several pdf files in a folder with this name for example:

2023-001-@max.pdf
2023-002-@anna.pdf
2023-003-@max.pdf

I would like to display a list of files that contain the string @max, preferably as a link!
I do not get there alone :frowning:

is that possible in any way?

You’re almost there! Simply add another condition (file.name.includes()) to your filter call:

const pdfFiles = app.vault.getFiles().filter(file => file.extension === 'pdf' && file.path.includes('Rechnungen') && file.name.includes('@max'))
dv.list(pdfFiles.map(file => dv.fileLink(file.path)))

edit: fixed typo in the script

1 Like

this is a great solution :slight_smile:
thank you very much for this.

one question, is it somehow possible to set a checkbox in front of each file in the output list?

I think that goes too far and is not so easy possible or?

it would be a dream, but i think not so easy :wink:

Just for completeness, this can also be done as an embedded search:

~~~query
@max path:"folder name"
~~~
1 Like

thanks for the tip.

that’s good to know.

it’s a pity that there is no possibility i think, to add a checkbox there.

Yeah, no checkboxes there, it’s just a search.

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