Solved

extract a specific file from zip directory

Posted on 2011-02-14
5
866 Views
Last Modified: 2012-05-11
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
0
Comment
Question by:rutgermons
5 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 34892753
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
0
 
LVL 14

Expert Comment

by:Michael Dyer
ID: 34892831
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.
0
 
LVL 52

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 34912891
According to the docs, this should work:

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

~bp
0
 

Author Comment

by:rutgermons
ID: 35392954
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
0
 
LVL 52

Expert Comment

by:Bill Prew
ID: 35392969
Great, glad you got it sorted out, thanks.

~bp
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now