
這個 Bash 腳本只下載幾個檔案就可以了,但我需要下載一百多個檔案。視覺化工具能夠下載文件的文件,但無法重新命名它們。
有人知道 Windows 實用程式會採用兩列文字列表,其中第一列將包含文件的完整 URL,第二列將包含用於重新命名的名稱?
答案1
您也可以使用 Download Accelerator Plus (DAP) 進行下載和重新命名。
您只需建立一個 DAP 列表,將其匯入應用程序,選擇要儲存檔案的資料夾,然後讓它完成工作。
要建立 DAP 列表,只需打開文字編輯器並為您要下載的每個文件輸入以下內容:
<filelist_index><fileinfo>
<filename>FILENAME.EXT</filename>
<url>FULL_URL_TO_FILE</url>
</fileinfo></filelist_index>
將 FILENAME.EXT 替換為您想要的檔案名稱(不要忘記檔案副檔名)。只需使用 MS Excel 合併程式碼,然後將它們複製並貼上到文字檔案中並將其另存為 XXX.DAP 檔案。這是一個電子表格範例:http://ge.tt/6sO1B2g
答案2
或者,使用 Windows powershell...
$folder = "D:\Output\"
$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)
$input = "D:\todownload.txt"
$delimit = " "
Get-Content $input |
Foreach-Object {
$line = $_.split($delimit);
$destination_file = ([io.path]::getfilename($line[1]))
"[" + $destination_file + "]" + "Downloading " + $line[0]
try {
$target = join-path $folder $destination_file
$web.DownloadFile($line[0], $target)
} catch {
$_.Exception.Message + ": " + $destination_file
add-content (join-path $folder ("downloader" + ".log")) ("[" + $destination_file + "] " + $_.Exception.Message)
add-content (join-path $folder ("downloader" + ".retry")) ($line -join " ")
}
}
輸入檔案(todownload.txt)的格式為:
http://path.to.download.com/file.jpg 0001_NewFileName_file.jpg
答案3
您可以嘗試一下 Firefox 擴充打倒他們!。它可以從一個頁面下載多個鏈接,您可以過濾下載列表並應用重命名模式。
答案4
perl -MLWP::Simple -n -e '($u,$n)=split;getstore($u,$n)' filenames.txt
(測試正常)
其中 filenames.txt 包含類似的內容
http://foo.com/a/b?parm=x this.dat http://bar.org//d/e/f.html that.html
較長形式的相同腳本
#!/usr/bin/perl 使用嚴格; 使用警告; 使用 LWP::簡單; 開啟我的 $fh, '<', "filenames.txt" 或死"無法讀取 filenames.txt 因為 $!\n"; 儘管 () { 我的($ url,$ newname)=拆分; getstore($url, $newname); }
(未經測試)