Discnumber Action


#1

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

e.g.

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

etc.

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?

Ta

mville


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

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

DD.20071125.1542.CET


#3

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.

Thanks

mville


#4

I have the answer

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

$ifgreater($strstr(%_directory%,'CD'),0,$num($mid(%_directory%,$add($strstr(%_directory%,'CD'),2),1),2),01)

Please let me know if there are errors with this.


#5

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)

DD.20071126.1759