gpt4 book ai didi

powershell - 我正在尝试使用不知道目标文件名的PowerShell来下载文件?

转载 作者:行者123 更新时间:2023-12-03 00:10:08 24 4
gpt4 key购买 nike

我正在使用以下脚本使用Powershell下载文件。

 $folder = "c:\temp\"
$userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101
Firefox/7.0.1"
$web = New-Object System.Net.WebClient
$web.Headers.Add("user-agent", $userAgent)


Get-Content "c:\temp\URL_List.txt" |
Foreach-Object {
"Downloading " + $_
try {
$target = join-path $folder ([io.path]::getfilename($_))
$web.DownloadFile($_, $target)
} catch {
$_.Exception.Message
}

}

URL_List.txt文件包含我要从中下载文件的URL的列表。以下是列表中的示例URL: https://drive.google.com/uc?export=download&id=0B84LPHCa2YmdZmFMV0dsYl9FeTg
如果您查看URL,则URL中没有绝对文件名,因此我不确定如何为WebClient.DownloadFile()方法设置目标参数。

最佳答案

阅读Download Files。由于您使用的是Powershell Google Drive REST Api module for Powershell,因此也可能值得检查。

关于powershell - 我正在尝试使用不知道目标文件名的PowerShell来下载文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50879537/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com