# 사용자로부터 입력 받기 $numberOfFiles = Read-Host "생성할 파일의 갯수를 입력하세요" $minSizeMB = Read-Host "최소 파일 크기(MB)를 입력하세요" $maxSizeMB = Read-Host "최대 파일 크기(MB)를 입력하세요" $directoryPath = Read-Host "파일을 생성할 디렉토리 경로를 입력하세요" # 입력된 값을 정수로 변환 $numberOfFiles = [int]$numberOfFiles $minSizeMB = [int]$minSizeMB $maxSizeMB = [int]$maxSizeMB # 디렉토리가 존재하는지 확인하고 없으면 생성 if (-not (Test-Path $directoryPath)) { $null = New-Item -Path $directoryPath -ItemType Directory } # 파일 생성을 위한 루프 for ($i = 1; $i -le $numberOfFiles; $i++) { # 랜덤한 파일 크기 생성 $fileSizeMB = Get-Random -Minimum $minSizeMB -Maximum ($maxSizeMB + 1) # 랜덤한 파일 이름 생성 $fileName = [System.IO.Path]::GetRandomFileName() $fileName = $fileName -replace '\.','' # 파일 생성 $filePath = Join-Path $directoryPath "$fileName.txt" $null = New-Item -Path $filePath -ItemType File # 파일 크기 조절 Set-Content -Path $filePath -Value (" " * $fileSizeMB * 1MB) # 생성된 파일 정보 출력 Write-Host "생성된 파일: $filePath, 크기: ${fileSizeMB}MB" } Write-Host "파일 생성이 완료되었습니다."