?
Solved

extract a specific file from zip directory

Posted on 2011-02-14
5
Medium Priority
?
883 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 56

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 56

Expert Comment

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

~bp
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

You may have already been in the need to update a whole folder stucture using a script. Robocopy does it well and even provides a list of non-updated files in a log (if asked to). Generally those files that were locked by a user or a process by the …
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
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

762 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