Use the denote-regexp package
The denote-regexp package by Samuel W. Flint defines utilities to write regular expressions that work with the Denote file-naming scheme in light of the user option denote-file-name-components-order (Change the order of file name components). The idea is to make it easier to perform complex queries like:
The regular expressions produced by denote-regexp can be used anywhere, such as in a Dired buffer to mark the matching files, in Org dynamic blocks, with the denote-add-links command, and more:
- Display filtered and sorted files with
denote-sort-diredordenote-dired. - Use Org dynamic blocks.
- Insert links to all files matching a query in their file name.
The denote-regexp documentation covers the technicalities: https://git.sr.ht/~swflint/denote-regexp.