obsidian-dataview icon indicating copy to clipboard operation
obsidian-dataview copied to clipboard

List other filetypes in vault

Open Spidrax opened this issue 3 years ago • 21 comments

I would like to be able to drop PDFs of articles related to a note into a folder in my vault and use dataview to generate a list of links to those files.

Such that this: list from "Articles"

Would result in a list of files in that folder:

  • Name of an article.pdf
  • Another different article.pdf
  • One more article.pdf

Spidrax avatar May 19 '21 14:05 Spidrax

Yes this would be a wonderful feature. +1!

Gregory-Esman avatar Aug 02 '21 06:08 Gregory-Esman

Most queries tend to operate over pages (over content within that pages), so this probably wouldn't become default behavior, though it will probably accessible pretty simply as so:

list from files("path")
where file.extension = 'pdf'

This is part of other work I am looking into for making dataview "FROM" statements much more expressive.

blacksmithgu avatar Aug 04 '21 05:08 blacksmithgu

Support this feature。

wujun001 avatar Sep 09 '21 09:09 wujun001

Both support and neeeeed this feature.

jowibou avatar Mar 10 '22 11:03 jowibou

@blacksmithgu I am wondering whether you have a rough estimate when this can be implemented. Like in a few months, this year, next year.. Queries over arbitrary files are essential for the vault am going to build, so I need to decide whether to stick with Obsidian or look elsewhere. Thanks.

youk avatar Jul 10 '22 20:07 youk

Are you just looking for "query links to all files with basic metadata like name and file type"?

blacksmithgu avatar Jul 10 '22 23:07 blacksmithgu

Basic metadata should be enough, yes – at least for now. But I'm not sure if "links" have a special meaning here. There's only a directory added (symlinked, to be exact) to the vault, nothing more.

youk avatar Jul 11 '22 06:07 youk

@youk you can use DVJS to grab info for non markdown files via the Obs API.

AB1908 avatar Jul 12 '22 09:07 AB1908

@AB1908 Thanks for the hint. That will do for now.

youk avatar Jul 12 '22 09:07 youk

@youk can you share the DVJS query you figured out?

huyz avatar Jul 27 '22 10:07 huyz

@huyz dv.list(this.app.vault.getFiles())

youk avatar Jul 27 '22 10:07 youk

Can add a filter to this to remove md files. .filter(t=>t.extension!="md") should be the idea here.

AB1908 avatar Jul 27 '22 11:07 AB1908

I use this DVJS to list other filetypes with name and folder.

const nonMdFiles = app.vault.getFiles().filter(file => file.name.includes('article') && file.path.includes('Articles') && file.extension != 'md' ); 
dv.list(nonMdFiles.map(file => dv.fileLink(file.path)))

nifanle7 avatar Jan 11 '23 13:01 nifanle7

I also would like to support this feature, even in the narrower scope; I use several markdown extension text files (like .rmd or .qmd or .txt which I am able to register as md in Obsidian through other extension; would be great to have possibilty to index these files in queries :)

danieltomasz avatar Mar 10 '23 11:03 danieltomasz

Daniel, would you like to PR this in? I can help guide and explain.

AB1908 avatar Mar 10 '23 13:03 AB1908

@nifanle7 Do you know where I can find an API reference to construct queries like you show? I'm not sure where to look for reference for things like app.vault.getFiles() and file.path.includes, etc and Google isn't helping. :)

Thanks

albertsj1 avatar Aug 03 '23 19:08 albertsj1

@albertsj1 your best bet is to open the console in dev tools and muck around with commands like app. Most of what you see in app is defined in the Obsidian API (but not all).

AB1908 avatar Aug 04 '23 22:08 AB1908

@albertsj1 your best bet is to open the console in dev tools and muck around with commands like app. Most of what you see in app is defined in the Obsidian API (but not all).

Just tried this out and I feel like a kid playing with a new toy. The autocompletion works so quickly. This is so cool. Thank you!

albertsj1 avatar Aug 17 '23 17:08 albertsj1

@AB1908 Sorry I didn't responded, I missed the message; I might try PR but indeed I will need some guidance (also I am not js/ts programmer, but good accasion to learn)

danieltomasz avatar Aug 17 '23 18:08 danieltomasz

Hey Daniel, we may want to put this on hold for now as blacksmithgu is working on a successor plugin (Datacore).

AB1908 avatar Aug 19 '23 13:08 AB1908

Are you just looking for "query links to all files with basic metadata like name and file type"?

I would like this feature as well since Obsidian currently doesn't have a good way to identify orphan attachments. I have an image folder that I use to embed images in notes, I want to have a way to query the attachments to see if any are not linked "to", so I know they are either orphaned or I need to link to them in a note. Dataview is great for orphaned notes, I'd just like the same for attachments.

Thanks!

phlepper avatar Dec 07 '23 00:12 phlepper