mIRC Homepage
Posted By: Ancyker Search and destroy - 17/02/03 07:32 AM
Need a script to find and delete a file type (.xcx) in a certin folder (C:\XCX\Files) but there are other files in the folder that i dont want deleted, im guessing I'd use the $findfile? i think thats it, anyway, I'd like to do it in the fastest manner possible, it has to be done with script though, thanks
Posted By: The_Game Re: Search and destroy - 17/02/03 08:11 AM
Or you could try another way that is included within windows its called "SEARCH" search for the files that you want to delete and then manually delete them....course thats just a thought LOL
Posted By: hyp0r Re: Search and destroy - 17/02/03 08:11 AM
Here ya go, this code should work pretty good!
Code:
alias delxcx {
  window -c @files | window -ln @files 180 60 200 300
  aline -s @files $findfile(C:\XCX\Files,*.xcx,@files)
  %lines = $sline(@files,1).ln | %position = 1
  while (%done != true && %lines > 0) {
    set %line $line(@files,%position)
    remove " $+ %line $+ "
    inc %position
    if (%position >= %lines) { %done = true }
  }
  unset %done %line %lines %position
  window -c @files
}

If there is more than say 1000 of these XCX files, mIRC might appear to hang while it's doing this, just wait it out, if you plan on having to delete a large amount of files often I can add a progress meter to this so you can see that it's doing something.
Posted By: The_Game Re: Search and destroy - 17/02/03 08:11 AM
Wait never mind i misunderstood....my bad!
Posted By: Hammer Re: Search and destroy - 17/02/03 09:04 AM
Code:

alias delxcx .!echo -q $findfile(C:\XCX\, *.xcx, 0, .remove $+(",$1-,"))
Posted By: xrn0id Re: Search and destroy - 17/02/03 12:42 PM
wouldnt: /remove C:/XCX/*.xcx work?
Posted By: gerdigos Re: Search and destroy - 17/02/03 01:46 PM
Hammer's code is best of all those stated, but if you want to expand it and make a window to tell you what it's deleting try:
Code:
 alias delxcx { 
var %a = 1, %b, %c = $1 
window @Clear
aline @Clear Started *.xcx deleting session in %c !
while ($findfile(%c,*.xcx,%a)) { 
set %b $ifmatch
remove %b
aline @Clear File: %b found and deleted (No: $+ %a $+ )
inc %a } 
if (%a == 1) { 
No .xcx file found in %c } 
} 

The directory is a variable in this case
© mIRC Discussion Forums