Need a little help with formatting an action for potentially empty field

Hi all,

First of all I'm sorry if this is asked before, I searched but cannot find an answer.

I'm setting up an action to rename filenames in a folder using the "Format value" action and setting _FILENAME for the field. What I'm trying to achieve:

  • Rename filenames that have a value for [discnumber] and [track] to [%discnumber%-%track. %artist% - %title%]
  • When there's no value for [%discnumber%], I would like it to be excluded from the new string, including the dash between [%discnumber%] and [%track%]!
  • Also, i would like no leading zeroes

So the filename of the first track in a batch of files looks like this:

  • With [%discnumber%]: [1-1. Cool Band - Nice Song]
  • Without [%discnumber%]: [1. Cool Band - Nice Song]

Thanks in advance!
Tim

Do you need the enclosing square brackets?
otherwise use:
Format string: [%discnumber%-]%track. %artist% - %title%
or with the brackets:
Format string: '['[%discnumber%-]%track. %artist% - %title%']'