$src = "D:\원본폴더"
$dst = "D:\모은파일"

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

$files = Get-ChildItem $src -Recurse -File
$total = $files.Count
$count = 0

foreach ($file in $files) {
    $count++
    Write-Progress -Activity "파일 복사 중..." `
        -Status "$count / $total : $($file.Name)" `
        -PercentComplete (($count / $total) * 100)

    $target = Join-Path $dst $file.Name

    if (Test-Path $target) {
        $base = [System.IO.Path]::GetFileNameWithoutExtension($file.Name)
        $ext  = $file.Extension
        $i = 1
        do {
            $target = Join-Path $dst "$base($i)$ext"
            $i++
        } while (Test-Path $target)
    }

    Copy-Item $file.FullName -Destination $target
}

Write-Host "완료! 총 $total개의 파일을 '$dst'에 복사했습니다."