Код:

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
}