The calibre save templates used for sending books to a device or saving to disk use the same template language as the plugboards use. The only extra thing to consider is that it generates the full path for the file without the extension. So, it can be used to create the directory structure.
There are a few suggestions in
Techniques to use plugboards, custom columns and templates and there is plenty of discussion in other places. From memory, there are a few suggests for fiddling with the series name in the shelf management sticky thread.