mIRC Home    About    Download    Register    News    Help

Print Thread
Removing leading numbers. #150321 31/05/06 07:54 PM
Joined: May 2006
Posts: 17
N
nelgin Offline OP
Pikka bird
OP Offline
Pikka bird
N
Joined: May 2006
Posts: 17
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

Re: Removing leading numbers. #150322 31/05/06 08:07 PM
Joined: Dec 2002
Posts: 1,245
M
MikeChat Offline
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
}

Re: Removing leading numbers. #150323 01/06/06 04:33 AM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
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.

Re: Removing leading numbers. #150324 01/06/06 12:07 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
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? -/