Hi,
Please check to see if this works.
$files = "C:\temp\file1.txt","C:\temp\file2.txt"
$results = "C:\temp\result1.txt","C:\temp\result2.txt"
for($i=0;$i -lt $files.Count;$i++){
$content = Get-Content -Path $files[$i] -Raw
[string]$output = $null
$count = 0
for($j=0;$j -lt $content.Length;$j++){
$output += $content[$j]
if(($content[$j] -eq " ") -or ($content[$j] -eq "`r") -or ($content[$j] -eq "`n")){
if(-not $whitespace){
$count ++
}
if($count%30 -eq 0){
$output += "`r`n"
}
$whitespace = $true
}
else{
$whitespace = $false
}
}
$output | Out-File -FilePath $results[$i]
}
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.