Problem adding year to path only if year tag exists

The $num() function does 2 things: convert any string in to a number (and be it that it gets a value of 0) and then adds padding according to the given additional number or digits.
So, $num(1000,2) does not convert the 1000 to 10 but leaves it as it is at 1000 as no additional leading zeros have to be added.

The expression

could be shortened to
[$num(%track%,2)]
as the square brackets serve as an $if() for fields
See the documentation about the characters with special functionality: