mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2003
Posts: 237
X
xrn0id Offline OP
Fjord artisan
OP Offline
Fjord artisan
X
Joined: Jan 2003
Posts: 237
im looking for a script that would scan for *.exe files, and compare them to a list. And if the exe is not on the list, it would delete it. ( I am working for my school on this one, and they need me to do that)



;Check for Life

if (%life == $null) {
goto getlife
}
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
This one worked:
Code:

;
; Example: /checkfiles mylist.txt c:\mirc\
;
; - Will remove any exe file from c:\mirc\ folder
;   which isn't listed in mylist.txt
;
alias checkfiles {
  if !$isfile($1) || !$isdir($2-) {
    echo -a Erroneous parameters. 
    return
  }
  window -h @files
  loadbuf @files $1
  var %num = $findfile($2-,*.exe,0,if (!$fline(@files,$1-)) .remove -b $+(",$1-,"))
  window -c @files
  echo * %num files were moved to the recycle bin.
}


Notice the -b switch used in the /remove command, to move these files to the recycle bin instead of complete removal (be careful with scripted /remove! smirk).

Joined: Jan 2003
Posts: 237
X
xrn0id Offline OP
Fjord artisan
OP Offline
Fjord artisan
X
Joined: Jan 2003
Posts: 237
it deletes every .exe in the folder. Whats an example of yoru mylist.txt ?



;Check for Life

if (%life == $null) {
goto getlife
}
Joined: Dec 2002
Posts: 1,922
O
Hoopy frood
Offline
Hoopy frood
O
Joined: Dec 2002
Posts: 1,922
Each line of mylist.txt is a file name followed by its full path.

Example: c:\programs\mirc\mirc.exe

You can ignore the value of %num, it will always return the total number of files exist in the folder, my mistake.

Joined: Jan 2003
Posts: 237
X
xrn0id Offline OP
Fjord artisan
OP Offline
Fjord artisan
X
Joined: Jan 2003
Posts: 237
i cannot get your scritp to work for some reason. how bout it will delete any file not on the list?



;Check for Life

if (%life == $null) {
goto getlife
}

Link Copied to Clipboard