Remove white space from empty field?

Hi, I’ve tried to search the forums and documentation but can’t seem to find an answer.

How do I prevent beets from resulting an empty white space when $catalognum doesn’t return anything?

E.g.: default: Albums$albumartist - $album ($year) %if{$catalognum,[$catalognum]} [$media]
Will result in:
Artist - Album (YEAR) [CD]
instead of
Artist - Album (YEAR) [CD]

see that extra space between year and cd?

edit: there is no extra space here as it seems to be removed on this forum automatically?
anyway, i assure you, there are two spaces between (YEAR) and [CD] when I run beets.

%if{$catalognum,[$catalognum ]}[$media]

Put the space inside the if so it only gets added if there’s actually a catalog number?

LMAO. Thanks, yeah. that worked.