I didn't want to complicate the question more than necessary, but I am using a third Various folder. I don't actually use it but it's there if I need it, and it doesn't change the problem.
$if(%soundtrack%,Soundtrack)\
$if(%soundtrack%,%date% - %album%)\
$if(%soundtrack%,$num(%tracknumber%,2) - %artist% - %title%)
$if(%soundtrack%,,$if(%various%,Various))\
$if(%soundtrack%,,$if(%various%,%date% - %album%))\
$if(%soundtrack%,,$if(%various%,$num(%tracknumber%,2) - %artist% - %title%))
$if(%various%,,$if(%soundtrack%,,Artist))\
$if(%various%,,$if(%soundtrack%,,%artist%))\
$if(%various%,,$if(%soundtrack%,,%date% - %album%))\
$if(%various%,,$if(%soundtrack%,,$num(%tracknumber%,2) - %title%))
(I am of course entering this on one line into the masstagger script thing)
Tracks which are neither under Soundtrack or Various come up fine because there are no unwanted \ characters afterwards; any Soundtracks get the \ appended and thus the problem.
To clarify, the desired result is, to take two examples;
\Artist\Opeth\2002 - Deliverance\03 - A Fair Judgement.ogg
\Soundtrack\1998 - Cowboy Bebop OST 1\05 - Yoko Kanno - Cat Blues.ogg