Код:

$aRootFolders = @('C:\Мои проекты\0203', 'C:\MyProjects\0002', 'C:\Мои проекты\0206', 'C:\Мои проекты\0207', 'C:\MyProjects\0003')
foreach($sRootFolder in $aRootFolders) {
if([System.IO.Directory]::Exists($sRootFolder)) {
Write-Host "[$sRootFolder]" -ForegroundColor Yellow
$aContent = @()
Get-ChildItem -Path $sRootFolder -Directory -Depth 1 |`
ForEach-Object -Process {
Write-Host " [$($_.Name)]" -ForegroundColor Green
Get-ChildItem -Path "$($_.FullName)\*.*" -File -Include "*.csv" |`
ForEach-Object -Process {
Write-Host " --> $($_.Name)" -ForegroundColor Cyan
$aCurrContent = [System.IO.File]::ReadAllLines($_.FullName)
if($aContent.Count -eq 0) {
$aContent += $aCurrContent
} else {
$aContent += $aCurrContent[1..$($aCurrContent.Count - 1)]
}
}
}
$sResultFileName = "$sRootFolder\$(([System.IO.DirectoryInfo]::new($sRootFolder).BaseName)).csv"
Write-Host "<-- $sResultFileName`r`n" -ForegroundColor Magenta
[System.IO.File]::WriteAllText($sResultFileName, [System.String]::Join("`n", $aContent))#>
} else {
Write-Host "Can't find root folder [$sRootFolder]." -ForegroundColor Red
}
}