Regex Findfile

By LIQUID_NiTrO on May 01, 2005

This is a regex version of the $findfile identifier.
Note that this identifier will take a good while to evaluate if there are lots of files in the folder, since it has to check EVERY file to see if it is a regex match. Works exactly the same as the normal $findfile, except that if you are specifying a command to perform on every match the $n identifiers will evaluate to the parameters you supplied in the alias, e.g. $1 will evaluate to whatever directory you specified. In place of these identifiers, you should use ~n
Ex. //echo Total: $ffreg($mircdir,/(mrc|ini)$/i,0,echo Match: ~1-) - echoes every .mrc and .ini file in the mIRC directory to the active window, then echoes the total number of .mrc and .ini files in the mIRC directory.
Note: ~n- is also supported and works the same as $n- would in $findfile

alias ffreg {
  var %x = 1
  var %c,%i = 0
  :regstupid
  while ( %x <= $findfile($1,*,0) ) {
    if ( $regex($findfile($1,*,%x),$2) ) {
      if ( $4 !iswm @* ) && ( $4 ) {
        var %nc = $replace($findfile($1,*,%x),\,$chr(200))
        .echo -q $chr(32) $regsub(param,$4,/(^|\s)\~(\d)($|\s|\-)/g,$chr(32) $+ $gettok(%nc,$iif($regml(param,3) == -,$regml(param,2) $+ -,$regml(param,2)),32),%com)
        if ( %i == 0 ) {
          inc %i 1
          goto regstupid
        }
        $replace(%com,$chr(200),\)
      }
      inc %c 1
      elseif ( $4 iswm @* ) {
        aline $4 $findfile($1,*,%x)
      }
      if ( $3 ) && ( %c >= $3 ) {
        return $findfile($1,*,%x)
        halt
      }
    }
    inc %x 1
  }
  return %c
}

Comments

Sign in to comment.
LIQUID_NiTrO   -  May 05, 2005

thanks and yep i am

 Respond  
Kancer   -  May 05, 2005

are you aka W-Unit? nice btw

 Respond  
Yoinx   -  May 03, 2005

In a single while loop like that, you can use Continue to jump back to the begining of the loop. Rather than using a goto like that.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.