I am attempting to extract text from a series of text files to a .txt document. The text files are stored in a series of sub-directories on the desktop.
So far, I can get the variables from a specific text file using a regular expression, but I need it to search through multiple files spanning across a number of directories - instead of the single file I direct it to.
$input_path = "C:\Users\Darren\Desktop\FolderofData\DataFile1.txt"
$regex = '(\W"_[a-z]+\W)'
$output_file = "C:\Users\Darren\Desktop\Extracted_Data.txt"
select-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $output_file
Is this possible in PowerShell?