If anyone's interested, here's an example of using a single template to simulate different templates for multiple libraries. I just set this as my save to disk template so that I could free up some disk space by consolidating my 3 copies of Calibre Portable while still keeping 3 different libraries. Thanks to eschwartz for giving me the idea for this template.
It uses the current_library_name function to identify which library you're working in, and the switch function to branch into different templates based upon each library.
Code:
program:
switch(current_library_name(),
'Calibre Library',
template('{#division}/{#genre}/{#authorlookup}/{series:||/}{series_index:0>3s||_}{#subseries}{#subseries_index:0>3s||_}{title}'),
'Library - Special',
template('{#group}/{title}'),
'Library - Working',
template('{author_sort}/{series}/{series_index:0>3s}_{title}'),
template('{author_sort}/{series}/{series_index:0>3s}_{title}'))
Ignore the specifics of the individual templates; they're just based upon the way I have my libraries set up. The important part to understand is that every pair of indented lines represents one library and the template to be used with that library. The final indented line is a fallback if the current library doesn't match any of the others, which in this case is the same template as my Working library.
To add more libraries, you just have to add another pair of lines. The library names are the folder names containing the libraries. This means it only works if your library folders have unique names even if they're in different parent folders.
Note that it works even if one of the templates uses custom columns that don't exist in a different library. For instance, my Main library does not have a Group column, but that doesn't stop me from using the Group column when saving to disk from my Special library.