Link to home
Start Free TrialLog in
Avatar of rutgermons
rutgermons

asked on

extract a specific file from zip directory

Folks

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
 
:NOFILE
echo.
echo       Sorry, the file:
echo       %SRC%\maximo.zip
echo       Was not found.
echo.
echo       Press any key to quit ...
pause > nul
 
:END
 
but how to i only extract a file called "tester.jar"  from maximo.zip?

all help will do
Avatar of sjklein42
sjklein42
Flag of United States of America image

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:

http://stahlworks.com/dev/index.php?tool=zipunzip
Avatar of Michael Dyer
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.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rutgermons
rutgermons

ASKER

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
Great, glad you got it sorted out, thanks.

~bp