Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Ветеран


Сообщения: 27449
Благодарности: 8087

Профиль | Отправить PM | Цитировать


То есть, все *.csv из всех подкаталогов первого уровня очередного «корневого» каталога объединяются в один, я правильно понимаю?

Попробуйте так:
Скрытый текст
Код: Выделить весь код
$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
    }
}
Это сообщение посчитали полезным следующие участники:

Отправлено: 16:29, 07-10-2018 | #17