title: Scala - Count number of files in directory with defined file extension
body: <p>Hi I have a script which batch converts pdfs into a series of images, what I'd like to do is count the total number of files in the directory that have the extension .jpg.</p>
  
  <p>So far I have</p>
  
  <pre><code>for (file &lt;- new File(path).listFiles) {
  
       /* DO SOMETHING */
  
  }
  </code></pre>
  
  <p>Is there a compact way of doing this without looping through each file?</p>
  
  <p>Thanks in advance, much appreciated :)</p>