title: Find file with certain extension and open the file in a program using a batch file
body: <p>I'm trying to search for a file that ends with *.ac and open that file in a program.
  There will always just be one file with this extension.
  The directory where the bat file will search is always the directory where it's running from.</p>
  
  <p>Currently this works:</p>
  
  <pre><code>@echo off
  for /r "%CD%" %%a in (*) do if "%%~nxa"=="myFileName.ac" set p=%%~dpnxa
  start /d "C:\Program Files (86)\CaseWare\" cwin32.exe "%p%"
  </code></pre>
  
  <p>But the myFileName.ac will always have a different name.</p>
  
  <p>I tried to change it to *.ac but then it doesn't work :(</p>
  
  <pre><code>@echo off
  for /r "%CD%" %%a in (*) do if "%%~nxa"=="*.ac" set p=%%~dpnxa
  start /d "C:\Program Files (86)\CaseWare\" cwin32.exe "%p%"
  </code></pre>
  
  <p>Any help please?</p>