我需要一個批處理文件中使用的命令,該文件通過http將遠程目錄的內容複製到本地目錄。在windows批處理文件中通過http複製目錄
比如複製文件夾中的http://路徑//文件夾複製到C:\文件夾
我需要做到這一點無需安裝任何額外的工具。
提前致謝!
我需要一個批處理文件中使用的命令,該文件通過http將遠程目錄的內容複製到本地目錄。在windows批處理文件中通過http複製目錄
比如複製文件夾中的http://路徑//文件夾複製到C:\文件夾
我需要做到這一點無需安裝任何額外的工具。
提前致謝!
http服務器沒有標準的方式來列出可訪問的目錄。
例如我把http://unomoralez.com/content/files/catalog2/source/作爲用http列出目錄的常用方法之一。你的網站可能看起來不一樣,但是沒有辦法讓我知道...(它是一個臨時的list2.txt
文件 - 你可以註釋它的刪除來檢查目錄頁面的格式並告訴我它是否不工作。如果它是IIS可以看像這樣:http://live.sysinternals.com/tools/)
腳本下載所有的內容到.\download_dir
(不遞歸下載):
@if (@X)==(@Y) @end /****** jscript comment ******
@echo off
::::::::::::::::::::::::::::::::::::
::: compile the script ::::
::::::::::::::::::::::::::::::::::::
setlocal
if exist simpledownloader.exe goto :skip_compilation
set "frm=%SystemRoot%\Microsoft.NET\Framework\"
:: searching the latest installed .net framework
for /f "tokens=* delims=" %%v in ('dir /b /s /a:d /o:-n "%SystemRoot%\Microsoft.NET\Framework\v*"') do (
if exist "%%v\jsc.exe" (
rem :: the javascript.net compiler
set "jsc=%%~dpsnfxv\jsc.exe"
goto :break_loop
)
)
echo jsc.exe not found && exit /b 0
:break_loop
call %jsc% /nologo /out:"simpledownloader.exe" "%~dpsfnx0"
::::::::::::::::::::::::::::::::::::
::: end of compilation ::::
::::::::::::::::::::::::::::::::::::
:skip_compilation
:: download the file
:::::::::::::::::::::::::::::::::::::::::
::::just change the link and the file::::
:::::::::::::::::::::::::::::::::::::::::
::!!!!!!!!!!!!!!!!!!!!!!!!!:::
simpledownloader.exe "http://unomoralez.com/content/files/catalog2/source/" "list2.txt"
md download_dir >nul 2>&1
for /f "skip=1 tokens=4 delims=>< " %%a in ('type list2.txt^| find /i "href" ') do (
simpledownloader.exe "http://unomoralez.com/content/files/catalog2/source/%%a" .\download_dir\%%a
)
del /q /f list2.txt
exit /b 0
****** end of jscript comment ******/
import System;
var arguments:String[] = Environment.GetCommandLineArgs();
var webClient:System.Net.WebClient = new System.Net.WebClient();
print("Downloading " + arguments[1] + " to " + arguments[2]);
try {
webClient.DownloadFile(arguments[1], arguments[2]);
} catch (e) {
Console.BackgroundColor = ConsoleColor.Green;
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\n\nProblem with downloading " + arguments[1] + " to " + arguments[2] + "Check if the internet address is valid");
Console.ResetColor();
Environment.Exit(5);
}
當你有powershell
你也有.net
所以這個代碼將不適合你的問題被執行。
這或多或少是我已經擁有的代碼,但是如果您熟悉cURL
並創建混合jscript/.bat文件,您也可以檢查這個代碼 - >https://code.google.com/p/curlie/。
PowerShell/.net(或至少vbscript/jscript)是否被視爲附加工具? – npocmaka 2014-09-01 08:37:47
Powershell可以使用。 – fanciulla 2014-09-01 08:38:38
我們需要看看你的嘗試。您如何計劃獲取目錄索引,因爲HTTP不提供這樣的機制? – CodeCaster 2014-09-01 10:04:38