Automate dataview -> plain text list / How to build a file.mdate-history?

My goal is to use daily notes to keep track of which files I modified at a specific day in the past. So, I created a dynamically generated dataview table that accesses file.mtime and compares it to the respective day, e.g. for today’s daily note:

LIST
FROM ""
WHERE file.mtime >= date(2023-01-20) AND file.mtime <= date(2023-01-21)
SORT file.name

The problem with this approach is, that as soon as I modify a file again a few days later, it will disappear from this list, since file.mtime will get updated.

Current work-around is to manually highlight and copy-paste the dataview at the end of the day.

Question: Can this extraction of the dataview-table into plain text be automated?

(I’m also open to alternative approaches towards a file.mdate-history/logger.)

One way forward is to use Templater to execute and insert the list into the note of your choice. This can for example be done in the javascript execution block, and triggering a dataview script.

Another option, building on the previous idea is to insert that code snippet into the creation og next days daily note, so that it updates the content og yesterday’s note.

Thank you for answering, @holroy . Maybe I’m overseeing something, but I am already using Templater to dynamically insert the dataview table via my daily notes template, like so:

` ` `dataview
LIST
FROM ""
WHERE file.ctime >= date(<%tp.file.title%>) AND file.ctime <= date(<%moment(tp.file.title,'YYYY-MM-DD').add(1, 'd').format("YYYY-MM-DD")%>)
SORT file.name
` ` `

However, this still creates a live-view dataview table, whereas, what I want to obtain is a plain text list, which will never be updated anymore. So how exactly would you make this conversion from dataview to plain text?

In this reply I’m answering on how to include stuff to be permanently saved into the new note, instead of being a dynamic query.

So the gist of how to do this is:

  • Use a Javascript execution command block, starting with <%*
  • Do your query and store the result, using something like either dv.query() or dv.tryQuery(), see Codeblock Reference - Dataview
  • And present the results back into the note by assigning the values into the tR variable, using something like dv.markdownList() to format the response.
  • Alternatively, especially if you don’t want/need to handle the storage/evaluation of the query result (which I most often want to tinker a little bit with), you can also do something like tR += await tryQueryMarkdown( ... )(I’ve not used this one, yet, so not entirely sure of the syntax, but try it out) (This step would replace the two preceding bullet points

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