Solved

extract a specific file from zip directory

Posted on 2011-02-14
5
864 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 51

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 51

Expert Comment

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

~bp
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 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

20 Experts available now in Live!

Get 1:1 Help Now