wget 대신 powershell을 사용한다면 …
구글알리미를 통해 poweshell을 검색어로 받은 뉴스인데
powershell을 공부하는 이에게 흥미있을 토픽일 것 같아서 공유를 합니다.
이 명령어 대신 쓸수 있는 powershell을 찾는다고 하네요.
Powershell equivalent for wget switches “-nc” and “-i”
wget -nc -i downloadList.txt
똑같지 않지만, … 힌트를 준다면 ….
Invoke-WebRequest -InFile
Powershell cmdlet 말고도 .Net class를 쓸수도 있지.
For -nc part, get contents of a file and select only unique strings with cat (alias for Get-Content) and sort (alias for Sort-Object). Then use wget (alias for Invoke-WebRequest) on this list of strings, extracting output file name from URLs with GetFileName
cat downloadList.txt | foreach {wget $_ -OutFile ([System.IO.Path]::GetFileName($_)
-nc 같이 정확히 동작하는 Powershell switch 없어.
It not only prevents overwriting a file. It also checks if the target file already exists and doesn’t start a second download. The whole point of -nc is to prevent the actual download.
case 1)
$folder = "D:\my\folder"
Compare $(Dir $folder).BaseName (gc "D:\downloadList.txt") -PassThru |
where {$_.SideIndicator -eq '=>'} |
foreach { wget $_ -OutFile "$folder\$_.html" }
case 2)
$folder = "D:\my\folder"
$exists = $(Get-ChildItem $folder).BaseName
$urls = Get-Content "D:\downloadList.txt"
$missing = Compare $exists $urls -PassThru | where {$_.SideIndicator -eq '=>'}
$missing | foreach { Invoke-WebRequest -Uri $_ -OutFile "$folder\$_.html" }
출처 : http://superuser.com/questions/981934/powershell-equivalent-for-wget-switches-nc-and-i