2014-09-01 1 views
0

원격 디렉토리의 내용을 http를 통해 로컬 디렉토리로 복사하는 배치 파일에서 명령을 사용해야합니다. // C 경로 // 폴더 : \ 폴더에 내가 어떤 추가 도구를 설치하지 않고이 작업을 수행 할 필요가Windows 배치 파일에서 http를 통해 디렉토리 복사

폴더에 http 복사 예를 들어

.

미리 감사드립니다.

+0

powershell/.net (또는 적어도 vbscript/jscript)는 추가 도구로 간주됩니까? – npocmaka

+0

Powershell을 사용할 수 있습니다. – fanciulla

+0

우리는 당신이 시도한 것을보아야합니다. HTTP가 그러한 메커니즘을 제공하지 않으므로 디렉토리 색인을 어떻게 구할 계획입니까? – CodeCaster

답변

1

http 서버가 액세스 가능한 디렉토리를 나열하는 표준 방법은 없습니다.

예를 들어 http로 디렉토리를 나열하는 일반적인 방법 중 하나는 http://unomoralez.com/content/files/catalog2/source/입니다. 귀하의 사이트가 다르게 보일 수 있지만 거기에 나를 알고있는 방법은 없습니다 ... (theres의 온도 list2.txt 파일 - 당신은 디렉토리 페이지의 형식을 확인하고 그것의 작동하지 않는 경우 말해 말해 삭제할 수 있습니다. http://live.sysinternals.com/tools/)

스크립트 .\download_dir에 모든 컨텐츠 (재귀하지 다운로드) 다운로드 :이처럼 당신이 powershell을 가지고

@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); 
} 

을 당신은 또한 .net 그래서이 코드는 당신을 위해 문제없이 실행됩니다있다.

이 코드는 이미 가지고있는 코드 였지만 cURL에 익숙하고 하이브리드 jscript/.bat 파일을 만들면이 코드를 확인해 볼 수 있습니다 (>https://code.google.com/p/curlie/).

관련 문제