This is untested, as I normally sort my files manually. For the few times I'd actually want to have a code to do it, it's not really worth it. However, I think this will do what you're asking for
Code:
 ;usage /filesort <directory> <pattern(s)>
alias filesort {
  if (!$1) { .msg $nick No directory specified }
  elseif (!$isdir($1)) { .msg $nick Directory $1 not found }
  elseif (!$2) { .msg $nick No file pattern specified }
  elseif (!$isdir($2)) { .md $2 }
  else {
    var %a = 1
    while %a <= $numtok($2-,32) {
      set %file $gettok($2-,%a,32)
      var %b = 1
      while %b <= $findfile($1,$+($2,.*),0) {
        .rename $findfile($1,$+(%file,.*),%b) $+(%file,\,$findfile($1,$+(%file,.*),%b))
        inc %b
      }
      inc %a
    }
  }
}
 

The directory specified is the starting directory for the search
multiple patterns are allowed, with each pattern being separated by spaces.
pattern is to be in the format of "name" only...no extensions