Discnumber Action


I want to populate the Discnumber tag from a string in the directory name.


If directory = 'Greatest Hits' then Discnumber = 01
If directory = 'Greatest Hits CD1' then Discnumber = 01
If directory = 'Greatest Hits CD2' then Discnumber = 02
If directory = 'Greatest Hits CD3' then Discnumber = 03


I think I need to use an Action, probably Format Value but I'm not sure what to enter in the Format String field.

Please can anyone help?



Help to create a parameter to rename folders
Automatic Discnumber tag from Directory Structure

Did you do a search for "discnumber" here in the forum?
If so, you should get many results, which can help you to learn how to solve your problem.

Especially this thread seems to be a good starting point:
Generating %DISCNUMBER% Tags



Yes, I did search the forums but with little understanding of the scripting functions I could not get a neat solution.

I will endeavour to crack the the $if and $regexp functions and post if a get a result.




I have the answer

(please note this will only work where the directory name contains CDn where n = 1 thru 9)


Please let me know if there are errors with this.


Right, this looks good to me.
You can make it a little bit more 'safe' by respecting the space character in the $strstr() functions.
$ifgreater($strstr(%_directory%,' CD'),0,$num($mid(%_directory%,$add($strstr(%_directory%,' CD'),3),1),2),01)

Try to understand how $regexp() works. A regular expressions e. g. can find a string fragment at end of the string, or e. g. can isolate only numbers at end of a string, and can help to solve so much more other problems you can think of.

$num($if($eql($regexp(%_directory%,'^.* CD(\d*)$','$1'),%_directory%),1,$regexp(%_directory%,'^.* CD(\d*)$','$1')),2)