title: Loop through folder changing file extensions VBA
body: <p>On a monthly basis I have to aggregate daily files.  The issue is I need the files to be in "TXT", but they are sent to me as "WRI".</p>
  
  <p>I am able to do one file at a time if it is hardcoded with the following.</p>
  
  <pre><code>Name "C:\Users\John\Desktop\Folder1\SQLEXEC.WRI" As "C:\Users\John\Desktop\Folder1\SQLEXEC.TXT"
  </code></pre>
  
  <p>However, I want to be able to loop through the folder. But I am not sure how to change the code to allow it to loop.</p>
  
  <pre><code>Sub ConvertToTXT()
  
  Application.DisplayAlerts = False 
  Application.ScreenUpdating = False
  
  Dim strPath As String 
  Dim strFile As String
  
  strPath = "C:\Users\John\Desktop\Folder1\" strFile = Dir(strPath &amp; "*.wri")
  
  Do While strFile &lt;&gt; ""
  
  Name "C:\Users\John\Desktop\Folder1\SQLEXEC.WRI" As "C:\Users\John\Desktop\Folder1\SQLEXEC.TXT"
  
  Loop
  
  End Sub
  </code></pre>