Remove leading zeros

When converting filename to tag, I would like to delete leading zeroes (if present) from the track numbers.
For example, file names contain numbers like 01, 02, ... 09, 10, 11 ...
I want the %track% tag to appear as 1, 2, ... 9, 10, 11

I know about the $num script to pad with leading zeroes, and the $trim script to remove leading whitespace, but I couldn't find one to remove leading zeroes.

Any suggestions?

There are a number of ways, but using $fmtNum() may be the simplest.

$num(%track%,1) or $trimleft(%track%,0)

A 3rd way:

Actiontype 5: Format value
Field: TRACK
Formatstring: $regexp(%track%,'^0{1}(.+)','$1')

Neither of these work when converting from filename to tag.

Would you please show me exactly how this would look in a filename to tag conversion?
I can't get it to parse any file names with this.

You can't use a function in a converter. Generally, you would first parse the name and end up with 01, 02, etc. in the TRACK field. Then you would apply the function to clean up the TRACK field using an action. After using the Filename-Tag converter you could use a Format value action in either a saved Action group or through an Action (Quick):

Action type: Format value
Field: TRACK
Format string: $fmtNum(%track%)

OR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

If you had file names that looked something like:

01 - Ornithology
02 - Scrapple from the Apple
03 - Parker's Mood

then you could use the following format string in the Filename-Tag converter to remove the leading zeros, but it would only work on tracks 1 through 9

0%track% - %title%

You would need to use the following format string for tracks 10+:

%track% - %title%

This would work, but IMO it's not worth the trouble of having to select different ranges of tracks, changing the format string and doing two conversions.

Not to nitpick, but I do routinely use functions in my Tag-Filename converter, e.g.

$validate([%discnumber%.][$num(%track%,2) - ][%artist% - ]%title%,-)

notice the use of the functions $validate and $num here.

Did you mean, "You can't use a function in the Filename-Tag converter"?

Thank you, JJ, this Action seems to do what I wanted. Too bad it has to be a separate action rather than a filter when the file name is being parsed.

Action type: Format value
Field: TRACK
Format string: $num(%track%,1)