Variable substitution in paths?

Is it possible to use variable substitution rather than hard coding the various work directory paths in Blender? I want to keep work files in a separate directory structure from .blend files and assets for storage space and backup reasons but it is a consistent structure along the lines of /$work_root/$blend_file. So while I may have /some/dir/structure/foo.blend, I would want render output to go somewhere such as /work/foo/ (with the usual subdirs such as cache_fluid etc. in this directory)… is there an easy way to accomplish this without hard coding the paths?