• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 892
  • Last Modified:

extract a specific file from zip directory


I have a batch that unpacks all files from a zipped file

@echo off

set SRC=C:\Daily\Received
set DEST=\\bp1xgbap670\Daily\Unpacked

for /f "tokens=1,2,3 delims=/" %%a in ('echo %DATE%') do set TODAY=%%a%%b%%c

REN "%SRC%\maximo.ear" "maximo.zip"
if not exist "%SRC%\maximo.zip" goto :NOFILE
REM -o is Destination folder
REM -p is Password to automatically enter - change this to suit
REM -y is option to accept all prompts
C:\Progra~1\7-Zip\7z.exe e -o"%DEST%\maximo"  -y "%SRC%\maximo.zip"

7z e -o"%DEST%\maximo"  -y "%SRC%\maximo.zip"
goto :END
echo       Sorry, the file:
echo       %SRC%\maximo.zip
echo       Was not found.
echo       Press any key to quit ...
pause > nul
but how to i only extract a file called "tester.jar"  from maximo.zip?

all help will do
1 Solution
There does not appear to be a way to extract particular files using 7z.

The (ostensible) excuse is that "7z's default behavior is to create "solid" archives for better compression. It is impossible to extract single files from such archives."

Personally, I use plain old, free unzip.exe which will do what you want.

Available many places, for example:

Michael DyerSenior Systems Support AnalystCommented:
this is easy with the command line pkunzip.exe utility

pkunzip  "%SRC%\maximo.zip" -e <filename>

This would extract the specific filename from the zip.
Bill PrewCommented:
According to the docs, this should work:

7z e "%SRC%\maximo.zip" -o"%DEST%\maximo" tester.jar -y

rutgermonsAuthor Commented:
bill, changed it a bit to work,thanks for the pointer

C:\Progra~1\7-Zip\7z.exe e -o"%DEST%\maximo"  "%SRC%\maximo.zip" businessobjects.jar -y
Bill PrewCommented:
Great, glad you got it sorted out, thanks.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now