I have a list of urls (urls.txt
):
https://example.com/1.webp
https://example.org/bar2.webp
... 10k more
Files vary in size from 1kb to 100kb.
How can I download these files quickly on a Windows 10 machine without installing any third-party software?
I need it to be in a single file that user can double-click without installing any additional software.
It should work on any decently up-to-date Windows 10 PC. AFAIK it means the PowerShell version is 5.1.
Additional information.
I tried this:
powershell -Command "Invoke-WebRequest https://example.com/1.webp -OutFile 1.webp"
but it extremely slow due to sequential execution.
So far this works in PowerShell fast enough:
Get-Content .\urls.txt |ForEach-Object {
$FileName = Split-Path -leaf $_
Invoke-WebRequest $_ -OutFile $FileName
}
But I can't figure out how to invoke this script with a double-click on a file.
Invoking .ps1
file from a .bat
file doesn't work. Error:
download.ps1 cannot be loaded because running scripts is disabled on this system.
Asking user to adjust permissions is not an option.
This works in a clickable .bat
file:
powershell -command ^
Invoke-WebRequest https://example.com/1.webp -OutFile 1.webp;
But this script fails silently:
powershell -command ^
Get-Content .\urls.txt |ForEach-Object { ^
$FileName = Split-Path -leaf $_ ^
Invoke-WebRequest $_ -OutFile $FileName ^
} ^