$regexp(%_directory%,.+(\d).*,$1)
That's what I'm using. It's simple but effective. It gives you the last number (single digit) of the directory name. That works almost for all sorts of folder naming schemes.
$regexp(%_directory%,.+(\d).*,$1)
That's what I'm using. It's simple but effective. It gives you the last number (single digit) of the directory name. That works almost for all sorts of folder naming schemes.
Wow- nothing like bring an eight year old thread back!
Thank you, that works nicely. It is so elegant once you know but it just didn't occur to me ![]()
this one with the condition, when the foldername contains "cd[number]", "CD[number]", "disc[number]" or "DISC[number]":
$if($and($isdigit($regexp(%_directory%,.+(\d).,$1)),$or($grtr($strstr($lower(%_directory%),'cd'),0), $grtr($strstr($lower(%_directory%),'disc'),0))),$regexp(%_directory%,.+(\d).,$1),)
Returns this expression the same result?
$regexp(%_directory%,'.*(?:cd|disc|disk)\s*0*(\d+).*','$1',1)resp.
$if($neql($regexp(%_directory%,'.*(?:cd|disc|disk)\s*0*(\d+).*','$1',1),%_directory%),$regexp(%_directory%,'.*(?:cd|disc|disk)\s*0*(\d+).*','$1',1),)... or ...
$if($eql($regexp(%_directory%,'.*(?:cd|disc|disk)\s*0*(\d+).*',,1),),$regexp(%_directory%,'.*(?:cd|disc|disk)\s*0*(\d+).*','$1',1),)DD.20140705.1230.CEST
Edit. Suppress leading zeroes.
DD.20140705.1852.CEST
nearly...
these are my test-folders:
a cd01 (test)
b disc02 (test)
cd 03 (test)
d disc 04 (test)
e keine disc
the first expression also creates 'eine' for the last folder, rest in two-digits (with a leading zero)
the second expression works nearly correct (no discnumber for the last folder), but the rest in two-digits (with a leading zero)
I have changed my formatstring in order to suppress leading zeroes, ...
now both formatstrings give nearly the same result.
Note: Prepare your formatstring also for discnumbers greater than 9.
Here is an export script with test cases ...
Test.20140705.ExtractCDNumber.mte (5.76 KB)
DD.20140705.1900.CEST
Test.20140705.ExtractCDNumber.mte (5.76 KB)
thx, now i've two alternatives ![]()