Task query

What I’m trying to do

I’m sorry for being such a dumbass, but I’m dyslexic and reading all the docs does my tiny nut in! I’m trying to limit a Tasks query so it does not include a specific folder. I’ve done the fancy callout view, and it worked fine until I tried adding ‘does not include’ line. I don’t get all the words that describe the process (pasted below.) It would be so much easier for a non programmer/left brained person if they just gave actual examples rather then trying to explain it in technical language… I’ve tried this but it’s obviously wrong -

> [!check] Tasks
> ```tasks
> not done
> folder does not include {{root/home/templates}}
> ```

Folder

Released

  • Introduced in Tasks 3.4.0.
  • Placeholders were released in Tasks 4.7.0.

This is the folder to the file that contains the task, which will be / for files in root of the vault.

  • folder (includes|does not include) <folder>
    • Matches case-insensitive (disregards capitalization).
    • Use {{query.file.folder}} as a placeholder for the folder of the file containing the current query.
      • For example, folder includes {{query.file.folder}}, which will match tasks in the folder containing the query and all sub-folders.
      • Useful reading: Query Properties and Placeholders
  • folder (regex matches|regex does not match) /<JavaScript-style Regex>/

Since Tasks 4.2.0, custom filtering by folder is now possible, using task.file.folder.

Since Tasks 5.1.0, the query’s file root can be used conveniently in custom filters:

filter by function task.file.folder === "Work/Projects/"
  • Find tasks in files in any file in the given folder only, and not any sub-folders.
  • The equality test, ===, requires that the trailing slash (/) be included.
filter by function task.file.folder.includes("Work/Projects/")
  • Find tasks in files in a specific folder and any sub-folders.
filter by function task.file.folder.includes( query.file.folder )
  • Find tasks in files in the folder that contains the query and any sub-folders.
filter by function task.file.folder === query.file.folder
  • Find tasks in files in the folder that contains the query only (not tasks in any sub-folders).
filter by function task.file.folder.includes("Work/Projects")
  • By leaving off the trailing slash (/) this would also find tasks in any file inside folders such as:
    • Work/Projects 2023/
    • Work/Projects Top Secret/

Things I have tried

I don’t use the Tasks plugin, but from what you pasted it looks like the curly braces may not be needed. Try folder does not include root/home/templates or folder does not include "root/home/templates". (If you need the quote marks, they should be straight ones ("", not “”).

Also I edited your post to mark the code as code and the huge quote from the docs as a blockquote.

1 Like

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