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

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

Ветеран


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

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


kontox, попробуйте так:
Скрытый текст
Код: Выделить весь код
$sRootFolder = 'C:\Мои проекты\0203'

if([System.IO.Directory]::Exists($sRootFolder)) {
    Get-ChildItem -Path $sRootFolder -Directory |`
        ForEach-Object -Process {
            Get-ChildItem -Path $_.FullName -File -Recurse -Include "*.csv" |`
                ForEach-Object -Begin {
                    $oFileInfo = $null
                } -Process {
                    if($_.Length -ge $oFileInfo.Length) {
                        $oFileInfo = $_
                    }
                } -End {
                    $oFileInfo
                }
        } | ForEach-Object -Begin {
            $aContent = @()
        } -Process {
            $aCurrContent = [System.IO.File]::ReadAllLines($_.FullName)

            if($aContent.Count -eq 0) {
                $aContent += $aCurrContent
            } else {
                $aContent += $aCurrContent[1..$($aCurrContent.Count - 1)]
            }
        } -End {
            [System.IO.File]::WriteAllText("$sRootFolder\$(([System.IO.DirectoryInfo]::new($sRootFolder).BaseName)).csv", [System.String]::Join("`n", $aContent))
        }
} else {
    Write-Host "Can't find root folder [$sRootFolder]." -ForegroundColor Red
}
Это сообщение посчитали полезным следующие участники:

Отправлено: 14:54, 30-09-2018 | #5