What I’m trying to do
So, I have this file called “Completed Tasks”. Basically, it is storing all the completed tasks, I use Achieve Tasks plugin to collect them all from pages into one. So, in “Completed Tasks” each line represent one completed task, which means number_of_lines = number_of_completed_tasks. Now, I want to show this number on my Homepage, how can I count the lines and show the number in markdown file, using some js function.
Things I have tried
I tried searching for the plugin or a command that would do that, could not find anything. I have this line showing me the total files number I have in my Vault “File Count:
$=dv.pages().length”. MB there is a similar command to find specific char in files.
There is no intrinsic command to get the number of lines in a file, that I know of. You can easily get the size of the file, which is close to the characters in the file (but not exactly the same due to unicode).
To get the number of lines you need to actually read the entire file, and count the number of line ending character(s). This is the general approach.
Are the lines in your file actual tasks, that is are they recognized by dataview as tasks? If so, you should be able to do a rather simple query to check for how many tasks are in that file.
Something along the lines of the following untested code:
in current file:
`= length(this.file.tasks) `
for some other file:
`$= dv.page("Completed Tasks").file.tasks.length `
Just found a documentation of Incline DQL, but could not find what I needed)
Actually, I was thinking about creating a plugin for this .
Thank you! You saved me a lot of hours.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.