title: is there a faster way than file or mdls to get file types on MacOS X in command line
body: <p>I want to get the file type of lots of files I'm finding with find.
  mime type would suffice, I need to know if they are images, videos, sound, documents etc</p>
  <p>So I'm doing</p>
  <pre><code>find &quot;$(pwd)&quot; -type f -print0  | xargs -0 file --mime-type
  </code></pre>
  <p>or</p>
  <pre><code>find  &quot;$(pwd)&quot; -print0  | xargs -0 mdls -name kMDItemKind
  </code></pre>
  <p>But they're &quot;slow&quot; 219 seconds for 55K files for find, 62 for mdls
  As I will need to catalog millions of files I need something faster</p>
  <p>stat for instance takes 2 seconds (but doesn't provide the file type, there's a Type but that's just folder vs regular file)</p>
  <p>Also, I'm not sure if mdls needs the spotlight index to be created before to get the data, or if it recomputes it (which would be safer, as I don't want to rely on a pre-existing index).</p>
  <p>Thanks</p>