# Problem adding year to path only if year tag exists

**URL:** https://community.mp3tag.de/t/problem-adding-year-to-path-only-if-year-tag-exists/65177
**Category:** Mac
**Created:** [July 1, 2024, 9:10am UTC](https://community.mp3tag.de/t/problem-adding-year-to-path-only-if-year-tag-exists/65177 "2024-07-01T09:10:28Z")
**Posts on this page:** 1
**Showing post:** 20

<div class="post-metadata">

### Author: ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)
#### Post date: [July 8, 2024, 3:43pm UTC](https://community.mp3tag.de/t/problem-adding-year-to-path-only-if-year-tag-exists/65177/20 "2024-07-08T15:43:19Z")

</div>

> [@Arbiter](#):
>
> `$if([%TRACK%],$num(%TRACK%,2),)`  
> It would be nice to account for those edge cases in the same action so I don't have to be concerned I'll forget and accidentally convert them all to two integer tracks.

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

> [@Arbiter](#):
>
> $if([%TRACK%],$num(%TRACK%,2),)

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:

> [@Format Strings and Available Placeholders](https://community.mp3tag.de/t/format-strings-and-available-placeholders/51688):
>
> Mp3tag uses format strings in various of its features to describe the structure of file names and imported data. A format string is built of either standard text (e.g., Music), placeholders (such as %artist%, %title%, ...), or slash characters / that usually denote directory structures. Characters with Special Functionality Some characters have special functionality and need to be treated with extra care. If you experience some unexpected behavior when using format string, check if some of t…

---

_[View the full topic](https://community.mp3tag.de/t/problem-adding-year-to-path-only-if-year-tag-exists/65177)._
