title: How do I create a batch file to search for file(s) with certain extension within a folder?
body: <p>Please help! I an new to creating batch files.</p>
  
  <p>I am trying to create a batch file to do the following things :</p>
  
  <ol>
  <li>Search for file(s) with a certain file extension (i.e. .docx) within a folder</li>
  <li>Output both filename(s) and extension to a text file (.txt)</li>
  <li>In the text file, I want to add an index before the file name</li>
  </ol>
  
  <p>For example, "folder 1" has these three files : test1.docx, test2.docx, test3.xlsx
  The batch file will search for these three files that have extension with .docx, and then output to a text file (i.e. search_result.txt)</p>
  
  <p>In the search_result.txt, it will have this format :</p>
  
  <p>1 test1.docx<br>
  2 test2.docx</p>
  
  <p>here is what I have so far which is doing #1 and #2 items mentioned above, but I need help to implement #3.</p>
  
  <pre><code>@echo off
  for /r %%i in (*.docx) do echo %%~nxi &gt;&gt; search_result.txt
  </code></pre>
  
  <p>Thank you in advance for the help.</p>