태그 보관물: directory-structure

directory-structure

파일을 다운로드하고 소스와 동일한 파일 구조를 만듭니다 로컬 컴퓨터에 디렉토리 구조

다운로드하려는 URI 목록으로 구성된 구성 파일이 있습니다. 예를 들어

  http://xyz.abc.com/Dir1/Dir3/sds.exe
  http://xyz.abc.com/Dir2/Dir4/jhjs.exe
  http://xyz.abc.com/Dir1/itr.exe

구성 파일을 읽고 각 URL을 복사하고 싶지만 동시에 호스트와 동일한 디렉토리 구조를 만듭니다. 예를 들어, 구성 파일의 첫 번째 줄에 대해 로컬 컴퓨터에 디렉토리 구조 Dir1 / Dir3 (없는 경우)을 만든 다음 sds.exe를 … / Dir1 / Dir3 /에 복사하려고합니다.

‘wget -i’를 사용하여 파일의 모든 URL을 다운로드 할 수 있지만 해당 디렉토리 구조를 어떻게 만들 수 있습니까?



답변

보낸 사람 man wget:

-x, –force- 디렉토리 :

[…]

디렉토리가 생성되지 않았더라도 디렉토리 계층을 생성합니다. 예를 들어 wget -x http://fly.srk.fer.hr/robots.txt 는 다운로드 한 파일을 fly.srk.fer.hr/robots.txt에 저장합니다.


답변

원하는 구조를 얻으려면 -n뿐만 아니라 -nH를 사용하는 것이 좋습니다.

이렇게하면 호스트 이름이 제거되고 예상 디렉토리 구조가 생성됩니다.

예 :

wget -x -nH http://xyz.abc.com/Dir1/Dir3/sds.exe

- 'Dir1/Dir3/sds.exe' saved [1234]

매뉴얼 페이지에서 :

-nH
--no-host-directories
   Disable generation of host-prefixed directories.  By default, invoking Wget with -r http://fly.srk.fer.hr/ will create a structure of directories beginning with fly.srk.fer.hr/.  This option disables such behavior.

-x
--force-directories
   ...create a hierarchy of directories, even if one would not have been created otherwise...


답변