To remove some tags from the files but still have the values available to use in the file naming script, you may first need to save them to temporary variables in a tagging script such as:
$noop( Create temporary variables )
$set(_temp_albumartist,%albumartist%)
$set(_temp_discnumber,%discnumber%)
$set(_temp_totaldiscs,%totaldiscs%)
$set(_temp_compilation,%compilation%)
$noop( Remove unwanted tags )
$delete(albumartist)
$delete(discnumber)
$delete(totaldiscs)
$delete(compilation)
Then the file naming script would use the variables that were created, rather than the tags that are being deleted. The file naming script might look something like:
$if(%_temp_compilation%,,$if2(%_temp_albumartist%,%artist%) - )%album%/
$if($gt(%_temp_totaldiscs%,1),%_temp_discnumber%-,)$num(%tracknumber%,2) %title%
$if($eq(%_temp_albumartist%,%artist%),, - %artist%)