Загрузка данных


$source = "C:\Path\To\Source"
$destination = "C:\Path\To\FlatPhotos"

New-Item -ItemType Directory -Force -Path $destination | Out-Null

Get-ChildItem -Path $source -Recurse -File | Where-Object {
    $_.Extension -match '\.(jpg|jpeg|png|heic|raw|cr2|nef|arw)$'
} | ForEach-Object {
    $destFile = Join-Path $destination $_.Name
    $baseName = $_.BaseName
    $ext = $_.Extension
    $i = 1

    # Если файл существует, дописываем _1, _2 и т.д.
    while (Test-Path $destFile) {
        $destFile = Join-Path $destination "${baseName}_$i$ext"
        $i++
    }

    Copy-Item -Path $_.FullName -Destination $destFile
}
Write-Host "Готово! Фотографии скопированы." -ForegroundColor Green