IPB

Welcome Guest ( Log In | Register )

> foobar2000 General Forum Rules

This is NOT a tech support forum.
Tech support questions go to foobar2000 Tech Support forum instead.

See also: Hydrogenaudio Terms of Service.

 
Reply to this topicStart new topic
Removing leading zeros from %tracknumber%
xordae
post Apr 17 2012, 15:05
Post #1





Group: Members
Posts: 24
Joined: 27-August 08
Member No.: 57563



Hi,

Can foobar2000 display the %tracknumber% variable in the playlist truthfully, i.e. without adding a zero for all numbers below 10? I would like to be able to sort it so I can determine which albums have not been formatted using 'Auto track number'.

Alternatively, is there a way to have Masstagger set up to truncate the leading zeros from %tracknumber%?

Since I keep multiple discs per folder, just doing an 'Auto track number' on the entire library will unfortunately screw it up.
Go to the top of the page
+Quote Post
Dario
post Apr 17 2012, 15:09
Post #2





Group: Members
Posts: 158
Joined: 20-September 11
Member No.: 93842



$num(%tracknumber%,1) will do that for you.

No idea about MassTagger, as I've never used it.
Go to the top of the page
+Quote Post
CoRoNe
post Apr 19 2012, 20:16
Post #3





Group: Members
Posts: 187
Joined: 31-May 05
From: Netherlands
Member No.: 22417



%subsong% instead of %tracknumber%?


--------------------
DC-Bass Source Mod: http://reino.degeelebosch.nl
Go to the top of the page
+Quote Post
db1989
post Apr 19 2012, 20:29
Post #4





Group: Super Moderator
Posts: 5275
Joined: 23-June 06
Member No.: 32180



Edit: What I previously said here was really wrong, so ignore me. Dario was right! Unless I’m mistaken, CoRoNe’s suggestion of subsong isn’t relevant.

This post has been edited by db1989: Apr 19 2012, 21:49
Go to the top of the page
+Quote Post
kode54
post Apr 19 2012, 23:51
Post #5





Group: Admin
Posts: 4695
Joined: 15-December 02
Member No.: 4082



$meta(tracknumber) should also work.
Go to the top of the page
+Quote Post
nevets1219
post Apr 19 2012, 23:56
Post #6





Group: Members
Posts: 46
Joined: 10-October 05
Member No.: 25022



For MassTagger ("Manage Scripts"), you can use "Format values from other fields" and set "Destination Field Name" to TRACKNUMBER and the pattern to "$num(%tracknumber%,1)" as previously suggested. I tested this on one particular album and it seems to work.

EDIT: You could select everything in your playlist but I'd perform some backup and/or tests to be sure the results are what you want.

EDIT: It seems to set songs without track number to track number zero. Be aware!

This post has been edited by nevets1219: Apr 20 2012, 00:00
Go to the top of the page
+Quote Post
db1989
post Apr 20 2012, 09:04
Post #7





Group: Super Moderator
Posts: 5275
Joined: 23-June 06
Member No.: 32180



QUOTE (nevets1219 @ Apr 19 2012, 23:56) *
EDIT: It seems to set songs without track number to track number zero. Be aware!
So use this:
CODE
[$num(%tracknumber%,1)]
The square brackets will have the expression return absolutely nothing (not a zero) if the field does not exist.

I just noticed: Technically, for fields whose literal value doesn’t have a leading zero, here you’d be adding one via %tracknumber% and then immediately removing using $num … but although this is redundant, the syntax is simple, and an expression that doesn’t do this is about five times longer—so never mind. tongue.gif
Go to the top of the page
+Quote Post
nevets1219
post Apr 20 2012, 17:23
Post #8





Group: Members
Posts: 46
Joined: 10-October 05
Member No.: 25022



I'm curious about the expression that doesn't do this, is it just an $if() expression or something fancier?
Go to the top of the page
+Quote Post
db1989
post Apr 20 2012, 18:11
Post #9





Group: Super Moderator
Posts: 5275
Joined: 23-June 06
Member No.: 32180



Actually, this entire thread somewhat requires clarification over whether the OP’s fields literally contain leading zeroes, or whether the problem is simply due to the (documented) behaviour of %tracknumber% padding to two digits when necessary.

In the latter case, this can be averted just by using $meta(tracknumber) to show the literal value, without any processing.

In the former case, we have the suggestions above, or the purist’s way:
CODE
[$num($meta(tracknumber),1)]

This is what you asked about, nevets1219; the reason I previously thought it might’ve been complicated was because I was uncertain whether square brackets supported $meta fields—which would have necessitated an $if, a $meta_test, and such—but then I verified via Wine that they do. As I said, it hardly matters, but this should provide the pleasant placebo of knowing that no zeroes will be added only to be taken away. tongue.gif (And now, before I ramble any more, I’m taking myself away…)

This post has been edited by db1989: Apr 20 2012, 18:13
Go to the top of the page
+Quote Post
nevets1219
post Apr 20 2012, 18:30
Post #10





Group: Members
Posts: 46
Joined: 10-October 05
Member No.: 25022



Is there some standard or at least encouraged standard for tracknumbers (e.g. leading zero or not)? I took a look here but couldn't find anything. I recently went through a semi-manual process of removing leading zeros but I stopped midway because it was very tedious (select an entire album, "Run Last Script") - but with the method discussed here, I could do everything in one sweep. Just not sure if it is worth the effort.
Go to the top of the page
+Quote Post
krafty
post Sep 3 2014, 02:10
Post #11





Group: Members
Posts: 282
Joined: 20-March 10
Member No.: 79175



Sorry to resurrect this thead. I am looking into doing the opposite: insert the leading zero on metadata. EAC creates it with leading zeros, so I want to keep them.
How to achieve this?
Go to the top of the page
+Quote Post
A_Man_Eating_Duc...
post Sep 3 2014, 03:38
Post #12





Group: Members
Posts: 944
Joined: 21-December 01
From: New Zealand
Member No.: 705



CODE
[$num($meta(tracknumber),2)]


--------------------
Who are you and how did you get in here ?
I'm a locksmith, I'm a locksmith.
Go to the top of the page
+Quote Post
d125q
post Sep 3 2014, 17:19
Post #13





Group: Members
Posts: 70
Joined: 4-May 13
Member No.: 107966



Does anybody know what is the difference between %track number% (*not* %tracknumber%; see the link) and $meta(tracknumber)?
Go to the top of the page
+Quote Post
Daeron
post Sep 3 2014, 17:46
Post #14





Group: Members
Posts: 454
Joined: 9-October 08
Member No.: 59818



QUOTE (d125q @ Sep 3 2014, 10:19) *
Does anybody know what is the difference between %track number% (*not* %tracknumber%; see the link) and $meta(tracknumber)?

There shouldn't be any. They do the same thing, which is returning the value of the TRACKNUMBER field without further modifications.

This post has been edited by Daeron: Sep 3 2014, 17:47
Go to the top of the page
+Quote Post
BenB
post Sep 3 2014, 17:56
Post #15





Group: Members
Posts: 778
Joined: 17-April 12
Member No.: 98921



Wouldn't $meta(tracknumber) bypass the foobar database and return the value as it is stored in the file whereas %tracknumber% and %track number% both access the value stored in the foobar database?

I don't know if the database stores single-digit values with or without leading zeroes, adding or removing them or what.

This post has been edited by BenB: Sep 3 2014, 17:58
Go to the top of the page
+Quote Post
Daeron
post Sep 3 2014, 18:23
Post #16





Group: Members
Posts: 454
Joined: 9-October 08
Member No.: 59818



The short test I did was:

Track number in properties: 1
%track number%: 1
$meta(tracknumber): 1
%tracknumber%: 01

Track number in properties: 01
%track number%: 01
$meta(tracknumber): 01
%tracknumber%: 01

Track number in properties: 1/5
%track number%: 1/5
$meta(tracknumber): 1/5
%tracknumber%: 1/5

By nature $meta(tag) should make a difference in most cases, as it ignores remappings but TRACKNUMBER has none. Perhaps if you installed one of the custom database components which would take over the field.
Go to the top of the page
+Quote Post
foosion
post Sep 3 2014, 19:10
Post #17





Group: FB2K Moderator (Donating)
Posts: 4489
Joined: 24-February 03
Member No.: 5153



QUOTE (BenB @ Sep 3 2014, 17:56) *
Wouldn't $meta(tracknumber) bypass the foobar database and return the value as it is stored in the file whereas %tracknumber% and %track number% both access the value stored in the foobar database?
The built-in functions and fields never access audio files directly. They only access the information which foobar2000 has already retrieved and cached.

QUOTE (BenB @ Sep 3 2014, 17:56) *
I don't know if the database stores single-digit values with or without leading zeroes, adding or removing them or what.
foobar2000 stores all fields as they are decoded by the associated input plugin. For most formats the value is returned as it is stored in the file.

QUOTE (Daeron @ Sep 3 2014, 18:23) *
By nature $meta(tag) should make a difference in most cases, as it ignores remappings but TRACKNUMBER has none.
%tracknumber% only checks the TRACKNUMBER tag but it does format the value. This is what is written in the title formatting help which you can access in foobar2000 from the Help menu:
QUOTE
Two-digit index of specified track within the album. Available only when “tracknumber” field is present in track’s metadata.


--------------------
http://foosion.foobar2000.org/ - my components for foobar2000
Go to the top of the page
+Quote Post
Daeron
post Sep 3 2014, 20:24
Post #18





Group: Members
Posts: 454
Joined: 9-October 08
Member No.: 59818



QUOTE (foosion @ Sep 3 2014, 12:10) *
QUOTE (Daeron @ Sep 3 2014, 18:23) *
By nature $meta(tag) should make a difference in most cases, as it ignores remappings but TRACKNUMBER has none.
%tracknumber% only checks the TRACKNUMBER tag but it does format the value. This is what is written in the title formatting help which you can access in foobar2000 from the Help menu.

I was referring to %track number%, not %tracknumber%, as per d125q's post. So no formatting applied.
Go to the top of the page
+Quote Post
BenB
post Sep 3 2014, 20:46
Post #19





Group: Members
Posts: 778
Joined: 17-April 12
Member No.: 98921



QUOTE (foosion @ Sep 3 2014, 13:10) *
The built-in functions and fields never access audio files directly. They only access the information which foobar2000 has already retrieved and cached.

Oh... so in a case where foo_playcount is installed, $meta(rating) returns the value stored by the foobar database and %rating% returns the value stored by the foo_playcount database?

Apparently, I got the impression that $meta(rating) retrieved the value from the file and assumed $meta() bypassed both databases. I don't remember why or how I got that impression.

QUOTE (foosion @ Sep 3 2014, 13:10) *
foobar2000 stores all fields as they are decoded by the associated input plugin. For most formats the value is returned as it is stored in the file.

I tested after posting and found this to be the case. %tracknumber% simply adds leading zeroes when none are present.

Thanks for your help.

p.s. - sorry for wasting your time, Daeron.

This post has been edited by BenB: Sep 3 2014, 20:47
Go to the top of the page
+Quote Post
krafty
post Sep 4 2014, 03:31
Post #20





Group: Members
Posts: 282
Joined: 20-March 10
Member No.: 79175



Man Eating Duck, thanks. That worked!
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 29th December 2014 - 16:01