mIRC Home    About    Download    Register    News    Help

Print Thread
#170534 10/02/07 10:45 AM
Joined: Dec 2006
Posts: 31
K
klaaamp Offline OP
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Dec 2006
Posts: 31
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?

klaaamp #170535 10/02/07 11:09 AM
Joined: Dec 2006
Posts: 80
Babel fish
Offline
Babel fish
Joined: Dec 2006
Posts: 80
Try this:

Code:
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
  }
}



Scripto ---- Life is about the relationships. The correct code being: $replace($them,$you,$me)
Scripto #170545 10/02/07 06:36 PM
Joined: Dec 2006
Posts: 80
Babel fish
Offline
Babel fish
Joined: Dec 2006
Posts: 80
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 *~*


Scripto ---- Life is about the relationships. The correct code being: $replace($them,$you,$me)
klaaamp #170546 10/02/07 06:45 PM
Joined: Dec 2002
Posts: 2,962
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
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.


Spelling mistakes, grammatical errors, and stupid comments are intentional.
Joined: Dec 2006
Posts: 80
Babel fish
Offline
Babel fish
Joined: Dec 2006
Posts: 80
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.


Scripto ---- Life is about the relationships. The correct code being: $replace($them,$you,$me)
Scripto #170560 11/02/07 12:56 AM
Joined: Oct 2005
Posts: 1,741
G
Hoopy frood
Offline
Hoopy frood
G
Joined: Oct 2005
Posts: 1,741
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.

-genius_at_work


Link Copied to Clipboard