Processing files in a directory tree
Your code is fine. Nevertheless, removing unnecessary braces can increase readability:

def traverse(dir: File, proc: File =&gt; Unit): Unit =
  dir.listFiles foreach { f =&gt; if (f.isDirectory) traverse(f, proc) else proc(f) }