Try this:
select-string '^>' filename.fasta | % {
$_ -replace '^.*\\(.*?)\.fasta:\d+:>(.*)$', "`$2`t`$1"
} > output.file
Note that your regular expression should be ^>
, not just >
. The latter would match >
anywhere in a line.
This can be applied to more than a single file like this:
$recurse = $false
Get-ChildItem "C:\base\folder" -Filter *.fasta -Recurse:$recurse `
| select-string '^>' `
| % { $_ -replace '^.*\\(.*?)\.fasta:\d+:>(.*)$', "`$2`t`$1" } > output.file