mIRC Home    About    Download    Register    News    Help

Print Thread
#150321 31/05/06 07:54 PM
Joined: May 2006
Posts: 19
N
nelgin Offline OP
Pikka bird
OP Offline
Pikka bird
N
Joined: May 2006
Posts: 19
It's been so long since I did much scripting, this has probably been done before smile

I have a list of mp3 files in a @window.

Some of them, however, have leading track numbers such as

01 - Genesis - Invisible Touch
02 - Genesis - Tonight, Tonight, Tonight

And some of them don't

REM - The Sidewinder Sleeps Tonite

Has anyone written a routeine to get rid only leading numbers and the dash and space?

TIA.
Mr Lazy wink

Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
try something like this
Code:
alias test {
  var %songname = 02 - Genesis - Tonight, Tonight, Tonight
  if ($left(%songname,1) isnum 0-9) { var %songname = $gettok(%songname,2-,45) }
    echo -s %songname
}

Joined: Aug 2005
Posts: 525
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
What if the band name starts with a number? wink

This matches and removes (if it is present) a song number consisting of 1 or 2 numbers followed by a space and a dash at the start of the string. Otherwise the string is returned as is.

Code:
alias nosongnum return $regsubex($1-,/^(?:\d|\d\d)\s-/,)


//echo -a $nosongnum(11th Song - One For Reality) --> 11th Song - One For Reality
//echo -a $nosongnum(1 - 11th Song - One For Reality) --> 11th Song - One For Reality
//echo -a $nosongnum(10 - 11th Song - One For Reality) --> 11th Song - One For Reality
//echo -a $nosongnum(01 - 11th Song - One For Reality) --> 11th Song - One For Reality

mIRC 6.17 is required for this to work since regsubex does not exist in previous versions.

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
That expression could be improved slightly.

/^(?:\d|\d\d)\s-/

(?:\d|\d\d) can become \d\d? - the "?" means that the second digit is optional, so it can be there but doesn't have to be.

\s will match any whitespace character ($cr, $lf, a tab, etc) so it's better to just use a space.

/^\d\d? -/


Link Copied to Clipboard