Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

extract a specific file from zip directory

Posted on 2011-02-14
5
Medium Priority
?
887 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 58

Accepted Solution

by:
Bill Prew earned 2000 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 58

Expert Comment

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

~bp
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

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…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

597 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