title: Vbscript to search for all files with an extension and save them to a CSV
body: <p>I am trying to write a script that will search say C:\ and all of its sub folders for a specific extension and save all of theme to a CSV file. I have tried this but to no avail:</p>
  
  <pre><code>Set objFSO = CreateObject("Scripting.FileSystemObject")
  objStartFolder = "C:\"
  
  Set objFolder = objFSO.GetFolder(objStartFolder)
  Wscript.Echo objFolder.GetExtensionName("*.txt")
  
  Set colFiles = objFolder.Files
  
  For Each objFile in colFiles
  If objFile.Extension = "pfx" Then
      Wscript.Echo objFile.Name
      End If
  Next
  Wscript.Echo
  
  ShowSubfolders objFSO.GetFolder(objStartFolder)
  
  Sub ShowSubFolders(Folder)
      For Each Subfolder in Folder.SubFolders
          Wscript.Echo Subfolder.Path
          Set objFolder = objFSO.GetFolder(Subfolder.Path)
          Set colFiles = objFolder.Files
          For Each objFile in colFiles
              Wscript.Echo objFile.Name
          Next
          Wscript.Echo
          ShowSubFolders Subfolder
      Next
  
  Set WScript = CreateObject("WScript.Shell")
  
  End Sub
  </code></pre>
  
  <p>I don't think I am going down the right path here. I am not proficient in the least in vb script it just happens to be the only thing I am allowed to use.</p>