mIRC Home    About    Download    Register    News    Help

Print Thread
listing files except for those specified #200288 01/06/08 07:11 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
What I'm trying to do, is find a way to list all of the files that are in a directory (and sub-directory/ies) that do not match certain extensions.

I know that $findfile will list those that match, so I guess I'm sort of looking for the reverse.

ie: $findfileexcept(c:\music,*.mp3;*.wav;*.ogg,0,echo -a $1-)
would return a list of files that are in c:\music (and any sub-directories) that don't match the listed extensions.

Re: listing files except for those specified [Re: RusselB] #200291 01/06/08 08:30 PM
Joined: Sep 2005
Posts: 2,876
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,876
This is going to be quite a lot slower than $findfile due to the extra processing but it does what you want:

Code:
alias -l process {
  var %i = 1
  while ($gettok(%ffe.types,%i,59)) {
    if ($v1 iswm $1-) return
    inc %i
  }
  inc %ffe.n
  if (@* iswm %ffe.command) && ($window(%ffe.command)) aline -l $v1 $1-
  elseif ($replace(%ffe.command,~file,$1-,~n,%ffe.n)) $v1
}
alias findfileexcept {
  if (($0 == 3) && ($isdir($1)) && ($3 isnum)) || (($0 == 4) && ($isdir($1)) && ($3 isnum)) || (($0 == 5) && ($isdir($1)) && ($3 isnum) && ($4 isnum)) !
  else return * Look up /help $!findfile to see the format for this identifier.
  set -u %ffe.n 0
  set -u %ffe.types $2
  if (($0 == 4) && ($4 !isnum)) || ($0 == 5) set -u %ffe.command $iif($5,$5,$4)
  noop $findfile($1,*,0,$iif($4 isnum,$4,999),process $1-)
  return %ffe.n
}


Takes the same options as $findfile, the only difference is that you must use ~file instead of $1- and ~n instead of $findfilen

Eg.

Code:
//echo -a ** $findfileexcept(C:\Documents and Settings\RusselB\My Documents\My Pictures,*.ithmb,0,3,echo -a ~n: ~file)

Re: listing files except for those specified [Re: hixxy] #200294 01/06/08 11:40 PM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline OP
Hoopy frood
OP Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
Thanks hixxy. Speed doesn't really make a big difference as it is just for my own usage