mIRC Homepage
Posted By: klaaamp write -c - 10/02/07 10:45 AM
If I have a subfolder in mirc-root that contains random files with random names and I want to clear them all with write -c, whats the best method todo this?
Posted By: Scripto Re: write -c - 10/02/07 11:09 AM
Try this:

alias clearall {
  var %a = $findfile(\whatever-the-folder-pathroot-is,*.txt,0)
  while (%a > 0) { 
    write -c $findfile(\whatever-the-folder-pathroot-is,*.txt,%a)
    dec %a

Posted By: Scripto Re: write -c - 10/02/07 06:36 PM
Heh... I just realized that /clearall is already an alias within mIRC, for clearing all windows' text.

Change that to /clearfiles or something... lol

*~* shrugs *~*
Posted By: starbucks_mafia Re: write -c - 10/02/07 06:45 PM
noop $findfile(foldername, *, 0, write -c $1).shortfn

That'll clear all files in foldername and in any subfolders of it aswell. If you just want to clear the files in that specific folder use:
noop $findfile(foldername, *, 0, 0, write -c $1).shortfn

Note: $findfile() as used above will also return the number of files cleared if you need it.
Posted By: Scripto Re: write -c - 10/02/07 07:08 PM
ahh yes, a demonstration of noop... cool.

Thanks starbucks_mafia, I saw the $1 command regarding findfile but wasnt sure how to set it up. /noop makes that nice.
Posted By: genius_at_work Re: write -c - 11/02/07 12:56 AM
Your code demonstrates one of the "don'ts" in mIRC coding. Using $findfile within a loop like that is incredibly inefficient. $findfile has its own looping mechanism (as demonstrated above) which is the most efficient method you can use.

© mIRC Discussion Forums