# 스크립트 시작 $directoryPath = "C:\users\admin\aws\s3sync" # 디렉토리 경로 설정 # 삭제할 아이템의 개수를 입력받음 $deleteCount = Read-Host "삭제할 아이템의 개수를 입력하세요" # 디렉토리 내의 파일 및 디렉토리 목록 가져오기 $items = Get-ChildItem -Path $directoryPath # 지워진 파일 개수 초기화 $deletedCount = 0 # 입력받은 숫자만큼 삭제 for ($i = 0; $i -lt $deleteCount; $i++) { $item = $items[$i] if ($item -ne $null) { $size = "{0:N2} MB" -f ($item.Length / 1MB) Write-Host "파일: $($item.Name), 크기: $size" Remove-Item -Path $item.FullName -Force -Recurse Write-Host "삭제됨: $($item.FullName)" $deletedCount++ } else { Write-Host "더 이상 삭제할 아이템이 없습니다." break } } # 지워진 파일 개수 표시 Write-Host "총 $deletedCount 개의 파일이 삭제되었습니다." # 스크립트 종료 Write-Host "스크립트가 종료되었습니다."