That's some of the worst coding I've seen from you Andy, you should know better by now...

Take a good look at your alias, it could be improved to work 1000 times faster. Remember, since a lot of people watch our posts, we should be careful not to teach other people bad scripting habits or inneficient coding.

Let's say his mp3 folder has 1000 mp3's in here (that's even being modest). That means:

1000 while iterations, with in each iteration you use a $findfile(%mp3dir,*.mp3,0) which returns the total amount of files in the folder. Can you imagine how long that takes? It has to look up 1000 times the amount of files in the folder. If there's anything worse than putting $lines(file) inside a while condition, it is $findfile. You should put the total files in a variable and reference that.

Inside the while loop, you are referencing the same file 3 times, being $findfile(%mp3dir,*.mp3,%x). That means 3000 times it has to look up this value == crappy. You should put the value in a variable, and reference that variable instead, will make a huge difference.

Lastly, a huge mistake here is to use write to write to a text file. As you know, for each /write operation, mIRC must open the specified file, write the string, and close it. Imagine doing that 1000 times, trust me it's very inefficient. You should atleast use the file handling commands. With /fopen, you open the file once, and then you can write to it, without each time opening/closing the file, with /fwrite. When you're done, you close the file with /fclose.

Anyway, even with the optimizations mentioned, it will still be highly inefficient because of the while loop. The best thing you can do here, is do 1 single $findfile call, and specify a custom alias in the command part of $findfile, which will take care of it.

Remember, $findfile is not an ordinary identifier like $gettok or the likes, which return a result much much faster. $findfile is an intensive identifier which should be used wisely. It has to scan a folder and all its subfolders (if no depth is specified), and check for each file if it matches the matchtext specified in $findfile. That takes much much longer than any other identifier.

Something along the lines of:

//!.echo -q $findfile(%mp3dir,*.mp3,0,myalias $1-)

alias myalias {
; $1- = filename
; your code here
}

Note that this code, as optimized as it is, will still choke on a lot of files. If you have 10000+ files, then don't expect this to finish in 20 seconds, it may very well take ages. Nothing that can be done about that, unless you resort to DLL's like whilefix, which has a builtin findfilecall command.


Gone.