title: Extract content from multiple txt files, then save files based on folder.filename
body: <p>I need search then extract content from multiple txt files and then save each search result to separate txt files, e.g. <code>serverabc.systeminfo.txt</code>.</p>
  
  <p>The below works however it returns all results to a single systeminfo.txt file that does not list what folder/file the results came from.</p>
  
  <p>Ideally I need a single file output for each systeminfo extraction. In the extracted folder there are multiple folders i.e. abc123, def456 etc. Each file needs to search systeminfo file within for either "abc software" or "def software" then if found output that result to a single text file, i.e. <code>abc123.systeminfo</code> etc.</p>
  
  <p>Once these files have been saved they will then be compared against a <code>master.txt</code> file for differences.</p>
  
  <pre><code>$path = "H:\Compare\Extracted"
  $Text = "abc Software"
  $Text2 = "def Software"
  $Results = "H:\Compare\Results\$($file.name).txt"
  $files = Get-ChildItem $path -recurse -Include *.txt
  
  foreach ($file in $files) {
      Get-Content $file |
         Select-String -Pattern $Text, $Text2 |
         select line |
         Out-File $Results -Append
  }
  </code></pre>