
나는 다음 명령을 알고 있습니다.
7z e [archive.zip]-o[outputdir] [fileFilter]
하지만 추출하려는 파일은 다른 Zip 내부의 Zip에 있습니다. 예를 들면 다음과 같습니다.
Archivo1.zip\Carpeta1\Archivo2.zip
이 줄을 사용했지만 결과적으로 아카이브를 찾을 수 없습니다.
C:\Program Files\7-Zip\7z" x "C:\File 1.zip\Folder 1\File 2.zip" -O"C:\Output folder" "Imagen 1.tif"
어떻게 일을 할 수 있나요?
답변1
7z 명령줄을 사용하여 다른 zip 내부의 zip에서 파일 추출
아래는 제가 몇 년 전부터 이 작업을 수행한 7Zip CLI 스크립트 방식입니다. 필요에 따라 수용하기 위해 한두 번 사용하고 조정해야 했습니다.
이는 추출할 다른 zip 파일이 남지 않을 때까지 다른 zip 파일(및 해당 내용) 내의 모든 zip 파일(및 해당 내용)을 추출하고 기본적으로 시작 [루트] 상위 zip 파일에서 마지막 하위 zip 파일 및 해당 내용까지 재귀적으로 통과합니다. ; 모든 zip 및 하위 zip 파일에서 파일을 추출합니다.
회사에서 이와 같은 데이터를 표준으로 전송하고 이를 변경할 수 없는 터무니없는 이유로 약 4단계를 통과하기 위해 이 방법을 사용했지만 그렇게 하도록 주어진 부분은 여전히 자동화할 수 있었습니다.
CLI 7za 배치 스크립트
필요에 따라 소스, 대상 및 작업 디렉터리 변수를 설정하고 파일을 소스 디렉터리 폴더에 복사한 다음 시작합니다. 그렇지 않으면 를 *.zip
사용하여 변경할 수 있습니다 <ParentZipFileName>.zip
.
:: This script uses the 7zip CLI to extract ZIP file(s) contents in one location to another
:: It then does an XCOPY of extracted ZIP files within the initial extacted files and copies those to a workdir
:: It then deletes ZIP files from source, and extracts the other ZIP files from workdir and loops until complete
:: NOTE that the 7za may need to have the environmental variable set accordinly
SET sourcedir=C:\Source
SET destdir=C:\Dest
SET workdir=C:\Workdir
IF NOT EXIST "%sourcedir%" MD "%sourcedir%"
IF NOT EXIST "destdir%" MD "%destdir%"
IF NOT EXIST "%workdir%" MD "%workdir%"
:unzip
7za -Y e "%sourcedir%" -o"%destdir%" -r
IF EXIST "%workdir%\*.zip" DEL /Q /F "%workdir%\*.zip"
XCOPY /Y /F "%destdir%\*.zip" "%workdir%\"
IF EXIST "%destdir%\*.zip" DEL /Q /F "%destdir%\*.zip"
DIR "%workdir%\*.zip" /A-D
ERRORLEVEL 1 GOTO done
:unzip2
7za -Y e "%workdir%" -o"%destdir%" -r
IF EXIST "%workdir%\*.zip" DEL /Q /F "%workdir%\*.zip"
XCOPY /Y /F "%destdir%\*.zip" "%workdir%\"
IF EXIST "%destdir%\*.zip" DEL /Q /F "%destdir%\*.zip"
DIR "%workdir%\*.zip" /A-D
IF ERRORLEVEL 1 GOTO done
GOTO unzip2
:done
GOTO EOF