
我知道這個指令:
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 檔案可供提取,並且本質上從起始[root] 父zip 檔案遞歸遍歷,直到最後一個子zip 檔案及其內容;從所有 zip 和子 zip 檔案中提取檔案。
由於某種荒謬的原因,我已經使用這種方法遍歷了大約四個級別,其中一家公司將這樣的數據作為標準發送並且無法更改它,但我仍然能夠自動化分配給我的部分。
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