Currently, I don’t know of a user-friendly or already implemented built-in way to do this so currently one needs a hacky workaround to do this for files (folders) as talked about in this thread (read through it to the end):
It could be done with Templater within Obsidian as well with TFile but I don’t remember where I’ve seen it applied.
Someone might write the code here.
Actually, this thread could be used to show people how to implement this.