Mixing templater and dataviewjs in a template

I have a dataviewjs snippet that lists a list of files, and when rendered those files are deleted by running a tp command:

dv.list(dv.pages().file.where(f => f.name.startsWith("Drawing ").path.map(path => "<%+ tp.user.delete_file({FILE_TO_REMOVE:'"+path+"'}) %>"))

The question is:
Instead of going to the note and render it so it removes the files, is there a way to put it into a template that when executed it acts as if it had been rendered?

Ok I think I found the way, working on it atm:

  • Create a new file from the template
  • Render it using some templater or obsidian api call
  • Remove it after run

This way I would be creating, rendering, and then deleting the template and the intended files would be deleted.

Ended up calling dv from within templater:


const dv = this.app.plugins.plugins["dataview"].api
const filesArray = dv.pages().file.where(f => f.name.startsWith("Drawing ") && f.name.endsWith("excalidraw")).where(f => f.inlinks == 0 && f.outlinks == 0).path
filesArray.map(path => {
tp.user.delete_file({FILE_TO_REMOVE: path})


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