I want to make dataviewjs query which finds orphan image

What I’m trying to do

I want to find query which shows unlinked image (like .jpg and .png) in attachment folder. This is because I used to keep image files in attachment folder and I want to find unlinked image to deleted it. I know there are plugins about this function but i want to solve it by using dataview.

Things I have tried

So, by using folder note plugin, i creat folder “JPNG” as a attachment folder and its folder notes ‘JPNG’. then, I wrote this query.

let parentFolder = dv.current().file.folder

const AllFiles = app.vault.getFiles()

.filter(file => file.extension && file.path.includes(parentFolder)&&  !file.name.includes("JPNG") && !file.inlink )

dv.paragraph(AllFiles.map(file => dv.fileLink(file.path)))

It was inevitable to use dataviewjs instead of dataview for finding non-md files. I use file.path to show only files which are in the “JPNG” and it did succeed. However, I failed to filter files which has inlinks. I have no idea about what function should i use. It would be thankful for advice :slight_smile:

1 Like