INTERACT FORUM
More => Old Versions => JRiver Media Center 31 for Windows => Topic started by: john greenwood on December 26, 2023, 02:55:06 pm
-
I am trying to set up an SDD music drive to be used with a player that can only search files. This is not all that difficult as my file structure mimics my normal search strategy.
But I do have one problem. I need to begin each file name with the track number for them to play in the same sequence as on the album. And if the track number is less than 10, I need to insert a '0' before the track number. I've been playing with the following:
=If([Track #] < 10, 0[Track #] [Name],[Track #] [Name])
The problem is all of my tracks - including those numbered 10 and above get the '0' added - i.e. the test expression always comes back true. That's not what I want.
I wondered whether it had something to do with numbers being treated as text characters, but I couldn't figure out how to overcome that. For instance I tried replacing 0 with Number(0), but it didn't seem to help.
-
Try
PadNumber([Track #],2)-[Name]
-
Thanks!
Oddly enough, so does: =If([Track #] > 9, [Track #] [Name], 0[Track #] [Name]) - i.e. flipping the expression around. If there's an error in the former version, I can't spot it.
In any event yours is much simpler.
-
If using the 'Rename, Move & Copy files' tool then just using
[Track #]-[Name]
in the Filename box gives (for example)
'Come Together.flac' is renamed as '01-Come Together.flac'
-
Alas - already copied. But after some testing to make sure there aren't surprises, I can do the PadNumber() in bulk.
-
The suggestion by @terrym@tassie works beautifully. But it leaves me with a puzzle.
Why does
=If([Track #] > 9, [Track #] [Name], 0[Track #] [Name])
work i.e. add the 0 padding when appropriate,
while
=If([Track #] < 10, 0[Track #] [Name],[Track #] [Name])
adds a 0 every time (no matter the track number)?
-
Because MC doesn't understand your syntax
both
if([Track #] > 9
if([Track #] < 10
are interpreted as different than zero (true). to do calculation you would need to use e.g. compare function
if(compare([Track #],>,9),no padding, padding)
if(compare([Track #],<,10),padding, no padding)
-
I see what you're saying. Compare() would seem to do the trick.
Although
=If([Track #] > 9, [Track #] [Name], 0[Track #] [Name])
does work.
-
MC expression syntax is slightly different than other programs, like Excel and many programming languages, where your expression would be fine.
In MC, "An expression is any sequence of literal text and any number of function calls" (Wiki). So, an expression does not understand numerical values except within a function, only literal text and expressions. [Track #] < 10 sees 10 as a literal, not an integer. The Compare function is used to compare 2 numerical values and is needed inn an expression to do the type of comparison you want. As I said, somewhat different but once you get caught once you remember it.