Powershell: create multiple .txt from one .txt with filenames from string Powershell: create multiple .txt from one .txt with filenames from string powershell powershell

Powershell: create multiple .txt from one .txt with filenames from string


You could read another line once your condition matches:

While (($Line = $Reader.ReadLine()) -ne $null) {    If ($Line -match "@") {        $OutputFile = $Reader.ReadLine()        Add-Content $OutputFile $Line        $Line = $OutputFile        $a++    }        Add-Content $OutputFile $Line}