title: Powershell: Convert text files to csv files
body: <pre><code>$SearchFolder = "C:\Test\New folder\*.txt" 
  
  
  $CSVFilePath = "C:\Test\txtfiles" # this doesn't work... 
  
  
  $File = Select-String -Path $SearchFolder -Pattern new-print-server, default, dymo, zebra -NotMatch | select line, filename
  
  
  
  $File | foreach-object {
  $_.line = $_.line.replace("^",",")
  
  }
  
  
  $File | export-csv -path $CSVFilePath -NoTypeInformation
  
  
  $csv = Get-Content -path $CSVFilePath
  
  
  
  $csv | Out-File $CSVFilePath -Encoding utf8
  
  
  Invoke-Item $CSVFilePath
  </code></pre>
  
  <p>This is a script I got from online and I would like to convert a folder of text files to csv files.
  This code only allows me to put all the txt files into one csv files.
  I would like to convert multiple txt files to multiple csv files with the same names.</p>