How to sort notes into folders by frontmatter value?

I have a template in Templater that adds two keys to the note: “class” (string) and “week” (integer). E.g.

---
class: cse1icb
week: 1
---

Is there any way to sort notes into folders by these keys:

(main folders for different classes [cse1icb, cse1iit, cse1pe, sta1dct])

(subfolders by week [1 to 12])

I believe this has been asked before, so you might find an answer by searching.