INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Excluding [Track #] Field in ListBuild Expression  (Read 276 times)

wraith

  • Recent member
  • *
  • Posts: 30
Excluding [Track #] Field in ListBuild Expression
« on: September 18, 2024, 09:04:18 pm »

Hi

I'm trying to create an expression that will rename my files in the format:
   [Album] - [Track #] - [Artist] - [Name]

with any empty fields being excluded from the name [including the " - " between].

The expression I've created so far is:

Code: [Select]
listbuild(1, / -/ ,
[Album,0],
[Track #, 0],
[Artist,0],
[Name,0]
)

The above is, so far, working with the string fields but I'm getting stuck with the [Track #] field. The [Track #] field replaces an empty field with "00", and I would prefer it excluded. I understand, from my web, expression wiki and forum searches, this behaviour is by design. As such, I've played around with FormatNumber, Delimit etc. and can't get it to be excluded.

Would appreciate feedback on how to exclude the [Track #] field [and, I'm presuming, any other numeric fields].

Thanks in advance
Logged
System: AMD Ryzen 5 5600X; 32Gb RAM
OS: Windows 11 Pro
MC: 30.0.96 (64-bit)

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2591
Re: Excluding [Track #] Field in ListBuild Expression
« Reply #1 on: September 19, 2024, 02:49:49 am »

Hi wraith, there are several ways. Try this one:
Code: [Select]
listbuild(1, / -/ ,
[Album],
if([Track #], [Track #],),
[Artist],
[Name]
)

This works by checking if [track #] is "false" (a zero value is false in the Expression Language).
Logged

wraith

  • Recent member
  • *
  • Posts: 30
Re: Excluding [Track #] Field in ListBuild Expression
« Reply #2 on: September 19, 2024, 03:50:01 am »

Hi zybex.

Thanks for helping out.

Tried your suggestion and still outputting "00". I'm still hunting. Any other ideas?

Logged
System: AMD Ryzen 5 5600X; 32Gb RAM
OS: Windows 11 Pro
MC: 30.0.96 (64-bit)

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2591
Re: Excluding [Track #] Field in ListBuild Expression
« Reply #3 on: September 19, 2024, 04:01:54 am »

Strange. The renaming tool does some weird things. Try:
Code: [Select]
listbuild(1, / -/ ,
[Album],
if(isempty([Track #]),,[Track #]),
[Artist],
[Name]
)

Or:
Code: [Select]
listbuild(1, / -/ ,
[Album],
if([Track #, 0], [Track #],),
[Artist],
[Name]
)
Logged

wraith

  • Recent member
  • *
  • Posts: 30
Re: Excluding [Track #] Field in ListBuild Expression
« Reply #4 on: September 19, 2024, 04:10:07 am »

No luck. Both those options still output "00" :(
Logged
System: AMD Ryzen 5 5600X; 32Gb RAM
OS: Windows 11 Pro
MC: 30.0.96 (64-bit)

zybex

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2591
Re: Excluding [Track #] Field in ListBuild Expression
« Reply #5 on: September 19, 2024, 04:14:52 am »

Well, let's try another way:
Code: [Select]
replace(listbuild(1, / -/ ,
[Album],
[Track #,0],
[Artist],
[Name]),- 00 -,-)
Logged

lepa

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 2033
Re: Excluding [Track #] Field in ListBuild Expression
« Reply #6 on: September 19, 2024, 10:13:47 am »

This should work also with RMC tool
Code: [Select]
listbuild(1, / -/ ,
[Album,0],
If(Compare([Track #],>,0),[Track #],),
[Artist,0],
[Name,0])

you can also add padding to track# make it look more clean in explorer
Code: [Select]
listbuild(1, / -/ ,
[Album,0],
If(Compare([Track #],>,0),PadNumber([Track #],2),),
[Artist,0],
[Name,0])
Logged

wraith

  • Recent member
  • *
  • Posts: 30
Re: Excluding [Track #] Field in ListBuild Expression
« Reply #7 on: September 19, 2024, 08:09:19 pm »

Hi Lepa,
The Compare function did the trick, thank you! :)

Hi Zybex,
Thanks for helping out, as well :)
Logged
System: AMD Ryzen 5 5600X; 32Gb RAM
OS: Windows 11 Pro
MC: 30.0.96 (64-bit)
Pages: [1]   Go Up