title: Groovy count number of files matches regex in the directory
body: <p>I am using this code to count number of files ends with 's' in a directory.</p>
  
  <pre><code>            def count=0
          def p = ~/.*s/
          new File("c:\\shared").eachFileMatch(p) { file-&gt;
              println file.getName().split("\\.")[0]
              count++
          }
          print "$count"
  </code></pre>
  
  <p>If there way to avoid the temp variable and use some method in File class itself?</p>
  
  <p>Thanks</p>