title: list files in folder and subfolders and output the result in multiple files for each parent folder
body: <p>I am using the code for listing files in a folder.</p>
  
  <pre><code>Dim fso
  Dim ObjOutFile
  
  Set fso = CreateObject("Scripting.FileSystemObject")
  Set ObjOutFile = fso.CreateTextFile(GetFiles(FolderName) &amp; "_"&amp;"OutputFiles.csv")
  
  ObjOutFile.WriteLine("Type,File Name,File Path")
  GetFiles("YOUR LOCATION")
  ObjOutFile.Close
  
  WScript.Echo("Completed")
  
  Function GetFiles(FolderName)
      On Error Resume Next
  
      Dim ObjFolder
      Dim ObjSubFolders
      Dim ObjSubFolder
      Dim ObjFiles
      Dim ObjFile
  
      Set ObjFolder = fso.GetFolder(FolderName)
      Set ObjFiles = ObjFolder.Files
  
      For Each ObjFile In ObjFiles
          ObjOutFile.WriteLine("File," &amp; ObjFile.Name &amp; "," &amp; ObjFile.Path)
      Next
  
      Set ObjSubFolders = ObjFolder.SubFolders
  
      For Each ObjFolder In ObjSubFolders
          ObjOutFile.WriteLine("Folder," &amp; ObjFolder.Name &amp; "," &amp; ObjFolder.Path)
          GetFiles(ObjFolder.Path)
      Next
  End Function
  </code></pre>
  
  <p>I am getting Output as _OutputFiles.csv</p>
  
  <p>If I run the script in a folder I want the output as</p>
  
  <pre class="lang-none prettyprint-override"><code>New Folder (3)_OutputFiles.csv
  New Folder (2)_OutputFiles.csv
  </code></pre>
  
  <p>with all files listed.</p>
  
  <p>Please suggest how to implement such that I get output for each parent folder separately.</p>