INTERACT FORUM

Please login or register.

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

Author Topic: Represent "Space" in Expressions  (Read 1363 times)

wraith

  • Recent member
  • *
  • Posts: 30
Represent "Space" in Expressions
« on: August 04, 2012, 04:58:02 am »

Hi All,

I'm trying to create an expression for renaming and relocating files based on the pre-set:
   [Artist] - [Album] - [Disc #]-[Track #] - [Name]

I'm attempting to modify it so that if any of the elements are missing that part of the filename is excluded. For example, If I don't know the album name, then file name would be:
   [Artist] - [Disc #]-[Track #] - [Name]
etc. etc.

I've, so far, prepared the following expression which almost works as I would like it to:
   if(IsEmpty([Artist]),,[Artist]) if(IsEqual([Album],unknown,8),,- [Album]) If(IsEmpty([Disc #],1),,- [Disc #])If(IsEmpty([Track #],1),,- [Track #]) If(IsEmpty([Name]),, - [Name])

The problem with this expression is the "spaces" (which I'll represent as " "). In the above example, if an field is empty the " " between each if statements is still entered into the expression. This has the effect of inserting a number of spaces between fields. For Example, if the Album, Disc # and Track # are missing, the file name would be:
   [Artist]    - [Name]

If I remove the space between each "if" statement, no space is put between the "-" and the next element. And a " " put before the "-" in each expression isn't recognised.

Has anyone attempted to resolve this issue and can assist? Or does anyone know how to represent a space character rather than a " " to put before the "-"

Any assistance would be greatly appreciated :)
Logged
System: AMD Ryzen 5 5600X; 32Gb RAM
OS: Windows 11 Pro
MC: 30.0.96 (64-bit)

vagskal

  • Citizen of the Universe
  • *****
  • Posts: 1227
Re: Represent "Space" in Expressions
« Reply #1 on: August 04, 2012, 05:33:22 am »

Try out the Clean() function.
Logged

MrC

  • Citizen of the Universe
  • *****
  • Posts: 10462
  • Your life is short. Give me your money.
Re: Represent "Space" in Expressions
« Reply #2 on: August 04, 2012, 10:12:26 am »

The listbuild() function will judiciously place separators between items, omitting empty ones.

   Listbuild(1, / -/ , [Artist], [Album,0], [Disc #,0], [Track #], [Name])

To literally input a space into an expression, use forward slash to escape it, as in:

   foo/ bar
Logged
The opinions I express represent my own folly.

wraith

  • Recent member
  • *
  • Posts: 30
Re: Represent "Space" in Expressions
« Reply #3 on: August 04, 2012, 09:53:46 pm »

Thanks for your input! I'll give it a go! :)
Logged
System: AMD Ryzen 5 5600X; 32Gb RAM
OS: Windows 11 Pro
MC: 30.0.96 (64-bit)
Pages: [1]   Go Up