title: How do you match an exact file extension under Windows/command line/file open dialog?
body: <p>I am trying to get a directory listing of only files with a given extension.  At first blush this seems to be a simple thing to do, however check out this simple example:</p>
  
  <pre><code>C:\CODE\metcal&gt;dir /b *.exe
  metcal.exe
  metcal.exe1
  </code></pre>
  
  <p>Notice that this returns <code>metcal.**exe**</code> and <code>metcal.**exe1**</code> as matches.</p>
  
  <p>With python files a similar thing happens:</p>
  
  <pre><code>C:\CODE\metcal&gt;dir /b *.py
  metcal.py
  metcal.pyc
  </code></pre>
  
  <p>Notice again Windows has determined that <code>*.py</code> takes anything that starts with <code>*.py</code> so it captures the <code>.pyc</code> files as well.</p>
  
  <p>Is there a way to get only the extensions that match exactly?  In the above python files example I would like the following to occur (obviously with the correct syntax substituted for *.py)</p>
  
  <pre><code>C:\CODE\metcal&gt;dir /b *.py
  metcal.py
  </code></pre>
  
  <p>As a note the matching under Windows not as simple as it seems.</p>
  
  <p><code>*.exe</code> matches  <code>foo.exe, foo.exe1, foo.exeabcde</code>  but <strong>not</strong> <code>foo.exe.bak</code></p>
  
  <p>There are other questions on SO that are similar that are related to long/short file names.  The *.py and *.pyc example here should not introduce name mangling machinery.</p>
  
  <p>**I have experimented on XP and Win7 machines and this behavior is not consistent at the cmd Prompt and file open dialogs.  This inconsistant behavior makes me suspect this problem is related to settings of somekind. **</p>