How to query pages that have names start with a certain set of characters?

For example: I have several pages with the names (their filenames, not the property title) starting with “abc”. Is there a way to query all those pages?

#+BEGIN_QUERY
{:title "Pages that start with abc"
 :query [:find (pull ?p [*])
         :where 
         [?p :block/name ?name]
         [(clojure.string/starts-with? ?name "abc")]]
}
#+END_QUERY

Note that the :block/name will always have the page names stored in small case, i.e., you will also get pages named with ABC, aBc, etc., in this query.

If you want only the pages starting with abc, then replace the :block/name with :block/original-name.

3 Likes

it worked! thank you!