규칙성을 가진 URL에서 다운로드 후 네이밍
$ScriptDir = Split-Path $script:MyInvocation.MyCommand.Path
$SubDir = $ScriptDir + "\qc"
<# 다운로드 경로 비우기 #>
New-Item -ItemType Directory -Force -Path $ScriptDir\qc
$arsource = @(
"https://cdn.qc.com/test1/test2/red/SETUP.EXE",
"https://cdn.qc.com/test1/test2/blue/SETUP.EXE",
"https://cdn.qc.com/test1/test2/white/SETUP.EXE",
"https://cdn.qc.com/test1/test2/black/SETUP.EXE",
"https://cdn.qc.com/test1/test2/yellow/SETUP.EXE"
)
<# 다운로드 후 파일 속성의 버전값 가져와서 리네임 #>
For ($i=0; $i -lt $arsource.Count; $i++){
$arsourcename = $arsource[$i].split("/")
$destination = $SubDir + "\test.exe"
$client = new-object System.Net.WebClient
$client.DownloadFile($arsource[$i], $destination)
$name = (Get-Item $destination).VersionInfo.ProductName
$version = (Get-Item $destination).VersionInfo.ProductVersion
$fullname = $arsourcename[4] + "_" + $version + "_" + $arsourcename[5]
Rename-Item $destination QC_$fullname.exe