Index with dataview for all pdf files?

hi

i hope someone can help me :slight_smile:

how can i list all external files in my vault?

for example all pdf files?

i have already tried this, unfortunately without success

list from ""
where contains(file.extension,"pdf")
1 Like

First point: define “external files”? are they placed in vault?
Second point: if they’re placed in vault you can’t achieve this via simple dataview. You can use dataviewJS and access to API with something like app.vault.getFiles().filter(file => file.extension == 'pdf'

1 Like

thank you for the feedback.

it is complicated for me
how exactly can i do this?
all my pdf files are in folder X in the vault

it does not work like this

app.vault.getFiles().filter(file => file.extension == 'pdf'

Evaluation Error: SyntaxError: missing ) after argument list
at DataviewInlineApi.eval (plugin:dataview:19669:21)
at evalInContext (plugin:dataview:19670:7)
at asyncEvalInContext (plugin:dataview:19680:32)
at DataviewJSRenderer.render (plugin:dataview:19701:19)
at DataviewRefreshableRenderer.maybeRefresh (plugin:dataview:19279:22)
at t.e.tryTrigger (app://obsidian.md/app.js:1:963725)
at t.e.trigger (app://obsidian.md/app.js:1:963658)
at t.trigger (app://obsidian.md/app.js:1:1520211)
at DataviewPlugin.eval (plugin:dataview:20684:76)
at a (app://obsidian.md/app.js:1:264427)

Try something like

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

If you want to specify the folder:

```dataviewjs
const pdfFiles = app.vault.getFiles().filter(file => file.extension === 'pdf' && file.path.includes('MyFolder'))
dv.list(pdfFiles.map(file => dv.fileLink(file.path)))
```
4 Likes

thank you :slight_smile:

this has helped me a lot. :pray:

have a nice time :slight_smile:

For a more effective organization of this forum, if you consider this help solved, please close this topic selecting the “solution”.
Thanks.

1 Like

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