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

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

Ветеран


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

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


На PowerShell:
Скрытый текст
Код: Выделить весь код
Param (
    [System.String]$sSourceFolder        = "C:\Sample",
    [System.String]$sDestFileNamePattern = 'mylist:.txt',
    [System.Int32]$iCountLimit           = 960

)

if([System.IO.Directory]::Exists($sSourceFolder)) {
    Get-ChildItem -Path "$sSourceFolder\*.*" -File -Include '*.jpg', '*.jpeg', '*.jpe' | ForEach-Object -Begin { $i = 1; $iCount = 1; $sContent = '' } -Process {
        $sContent += "file '$($_.Name)'`r`n"

        if($i -ge $iCountLimit) {
            $sResultFile = "$sSourceFolder\$($sDestFileNamePattern.Replace(":", $iCount.ToString("0000")))"
            Out-File -InputObject $sContent -FilePath $sResultFile -Encoding ASCII -NoNewline

            Write-Host "[$sResultFile] : $i file(s)." -ForegroundColor Cyan
            
            $i = 1
            $iCount++
            $sContent = ''
        } else {
            $i++
        }
    }

    if($sContent -ne '') {
        $i--
        $sResultFile = "$sSourceFolder\$($sDestFileNamePattern.Replace(":", $iCount.ToString("0000")))"
        Out-File -InputObject $sContent -FilePath $sResultFile -Encoding ascii

        Write-Host "[$sResultFile] : $i file(s)." -ForegroundColor Cyan
    }
} else {
    Write-Host "Can't find source folder [$sSourceFolder]." -ForegroundColor Red
}

Файлы никак не сортируются.
Это сообщение посчитали полезным следующие участники:

Отправлено: 17:25, 07-08-2018 | #4