create a filename with optional portions


#1

Hi, I would like to rename my files according to this scheme:

  • If there is not track number, I want my filename like this: Artist - Title
  • If there is track number then the name should follow this schme: (track) Artist - Title

I tried to use this action, but it doesn't work. What am I doing wrong?
$validate($if($isdigit(%track%),'('$num(%track%)') ',2),)%artist% - %title%,_)


#2

You could use the converter Tag-Filename and the mask
[(%track%) ]%artist% - %title%
The square brackets enclose the optional part


#3

Unbelievable. Who would say it's so easy.
Thank you.


#4

If it is crucial for your naming filenames, that %track% has to be a number, this is the optional %track% part like you wanted it in the first way:

$if($isdigit(%track%),'('$num(%track%,2)')' ,)


#5

Not sure how much detail you want in your filenames but this is how I like my filenames....

If I have multi disc sets then I append the discnumber as in the format below. Inversely, no multi disc just %track% %title%

%discnumber%-%track% %title%

For example:

The Album "Days of Rising Doom" from AINA. Disc 2, Track 2 would look like this:

2-17 The Beast Within

(I also number all tracks sequentially from 1 - number of tracks ... this seems to make it easier for some apps in the sorting process I have found)

I suppose the mechanics of it may be a bit confusing. But if you have the field %totaldiscs% or an equivalent this will work in your action group ...

Action:Format Value

  1. Field: _FILENAME
  2. Format String: $ifgreater(%totaldiscs%,1,$left(%discnumber%,2)-$num(%track%,2) %title%,$num(%track%,2) %title%)

Hope this helps you....


#6

Try this format string expression with an action of your choice ...

$if(%TRACK%,'('$num(%TRACK%,2)') ',%DUMMY%)%ARTIST%' - '%TITLE%)

If you want to prepend the running disc number, then try this expression ...

$ifgreater(%TOTALDISCS%,1,$num(%DISCNUMBER%,1)'-',%DUMMY%)$if(%TRACK%,'('$num(%TRACK%,2)') ',%DUMMY%)%ARTIST%' - '%TITLE%)

DD.20120436.0636.CEST


#7

Thank you all for your tips.