mIRC Home    About    Download    Register    News    Help

Print Thread
#152693 04/07/06 06:12 PM
Joined: Feb 2006
Posts: 164
V
vexed Offline OP
Vogon poet
OP Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
Code:
 alias mp3stats {
  set %wild.card $$1-
  set %all.mp3s $findfile(%mp3.dir,*.mp3,0)
  set %wild.total $findfile(%mp3.dir,* $+ %wild.card $+ *,0)
  set %wild.percent1 $calc(%wild.total / %all.mp3s)
  set %wild.percent.complete $calc(%wild.percent1 * 100)
  say total of %wild.total mp3s containing the string " $+ %wild.card $+ " which makes it $round(%wild.percent.complete,2) $+ $chr(37) of my %all.mp3s mp3s
} 


This alias is quite handy for checking how many mp3's you have of a certain criteria, ie:

total of 77 mp3s containing the string "prodigy" which makes it 2.52% of my 3050 mp3s

when i added the * wildcard in i got this

total of 3337 mp3s containing the string "*" which makes it 109.41% of my 3050 mp3s
any idea what's wrong? thanks in advance.

#152694 04/07/06 08:51 PM
Joined: Dec 2002
Posts: 1,245
M
Hoopy frood
Offline
Hoopy frood
M
Joined: Dec 2002
Posts: 1,245
not sure where you are adding that "*"
I played with your
Code:
alias mp3stats {
  set %wild.card * $+ $replace($$1-,$chr(32),*) $+ *.mp3
  set %all.mp3s $findfile($mp3dir,*.mp3,0)
  set %wild.total $findfile($mp3dir,%wild.card,0)
  set %wild.percent $calc((%wild.total / %all.mp3s) * 100)
  say total of %wild.total mp3s containing the string " $+ %wild.card $+ " which makes it $round(%wild.percent,2) $+ $chr(37) of my %all.mp3s mp3s
  unset %wild.*
  unset %all.mp3s
}


I really see no reason to Set those variables as they are not used outside of the alias

I think local vars are better to use
you will need to usnset them before testing this
Code:
alias mp3stats {
  var %wild.card = $+(*,$replace($$1-,$chr(32),*),*.mp3)
  var %all.mp3s = $findfile($mp3dir,*.mp3,0)
  var %wild.total = $findfile($mp3dir,%wild.card,0)
  var %wild.percent = $calc((%wild.total / %all.mp3s) * 100)
  msg $active total of %wild.total mp3s containing the string " $+ %wild.card $+ " which makes it $round(%wild.percent,2) $+ $chr(37) of my %all.mp3s mp3s
}

#152695 05/07/06 12:53 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
When you do /mp3stats prodigy the script uses $findfile to count the files that match *.mp3 (to find the total mp3 files) then it uses $findfile again to count the files that match *prodigy* which returns 77 in this case.

When you do /mp3stats * the script searches for *.mp3 as before, but now it searches for * which matches EVERYTHING in that folder, including files that are NOT mp3s.

The changes given in the second example above should fix the problem, except I would change this line:

var %wild.card = $+(*,$replace($$1-,$chr(32),*),*.mp3)

to this:

var %wild.card = $+(*,$replace($$1-,$chr(32),*,.mp3,),*.mp3)

in case someone searches for *prodigy*breath*.mp3 the .mp3 will be removed so it isn't duplicated by the code.

-genius_at_work

Last edited by genius_at_work; 05/07/06 01:00 AM.
#152696 05/07/06 08:27 AM
Joined: Feb 2006
Posts: 164
V
vexed Offline OP
Vogon poet
OP Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
With all due respect, it doesn't work at all now lol

#152697 05/07/06 03:25 PM
Joined: Jul 2006
Posts: 10
O
Pikka bird
Offline
Pikka bird
O
Joined: Jul 2006
Posts: 10
Code:
alias mp3stats {
  set %wild.card $+(*,$replace($$1-,$chr(32),*,.mp3,),*.mp3)
  set %all.mp3s $findfile(%mp3.dir,*.mp3,0)
  set %wild.total $findfile(%mp3.dir,%wild.card,0)
  set %wild.percent1 $calc(%wild.total / %all.mp3s)
  set %wild.percent.complete $calc(%wild.percent1 * 100)
  msg $active Total of %wild.total mp3s containing the string " $+ %wild.card $+ " which makes it $round(%wild.percent.complete,2) $+ $chr(37) of my %all.mp3s mp3s
  unset %wild.*
  unset %all.mp3s
}


*DURING TEST*

[1:20:43] [@Axl] Total of 103 mp3s containing the string "*Pantera*.mp3" which makes it 2.81% of my 3663 mp3s
[1:21:21] [@Axl] Total of 9 mp3s containing the string "*Korn*Away*.mp3" which makes it 0.25% of my 3663 mp3s
[1:21:52] [@Axl] Total of 0 mp3s containing the string "*Zorbas*Dance*.mp3" which makes it 0% of my 3663 mp3s
[1:22:00] [@Axl] Total of 1 mp3s containing the string "*Zorba's*Dance*.mp3" which makes it 0.03% of my 3663 mp3s


-------------------------

as far as i can tell this script also works in subdirectories inside your "%mp3.dir" but im not 100% sure

#152698 05/07/06 04:08 PM
Joined: Feb 2006
Posts: 164
V
vexed Offline OP
Vogon poet
OP Offline
Vogon poet
V
Joined: Feb 2006
Posts: 164
Yeah i went back to that and it's alright.

Cheers guys. smile


Link Copied to Clipboard