Batch unzip

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
d_a_r_k
Posts: 5
Joined: 18 Feb 2010 05:50

Batch unzip

#1 Post by d_a_r_k » 22 Feb 2010 13:57

Hello, I want to make a batch file which reads computer for specified archive name and when he does find it - extract contents of the archive to directory from where the batch file has been executed.

The archive is in .7z format for this to work we will need 7-Zip Command Line version http://sourceforge.net/projects/sev...

If someone knows how to use it, could you please help me with this?

Thanks in advance :)

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Batch unzip

#2 Post by !k » 22 Feb 2010 16:35

d_a_r_k wrote:directory from where the batch file has been executed
Current dir? Use %cd% var:

Code: Select all

7z e archive.zip -o"%cd%" *.* -r

d_a_r_k
Posts: 5
Joined: 18 Feb 2010 05:50

Re: Batch unzip

#3 Post by d_a_r_k » 22 Feb 2010 17:04

I get an error "cannot find archive"

d_a_r_k
Posts: 5
Joined: 18 Feb 2010 05:50

Re: Batch unzip

#4 Post by d_a_r_k » 22 Feb 2010 17:10

Maybe it is possible to make batch file find this specific archive location and put the destination path to 7-Zip command line for extraction?

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Batch unzip

#5 Post by !k » 22 Feb 2010 18:21

Quite so.

Code: Select all

7z e "d:\full path\archive.zip" -o"%cd%" *.* -r

d_a_r_k
Posts: 5
Joined: 18 Feb 2010 05:50

Re: Batch unzip

#6 Post by d_a_r_k » 22 Feb 2010 23:26

Unfortunately I still get the same error, it cannot find the specified archive.

!k
Expert
Posts: 378
Joined: 17 Oct 2009 08:30
Location: Russia

Re: Batch unzip

#7 Post by !k » 23 Feb 2010 03:06

Try to use the full path to 7z.exe
Image

d_a_r_k
Posts: 5
Joined: 18 Feb 2010 05:50

Re: Batch unzip

#8 Post by d_a_r_k » 23 Feb 2010 10:12

This method does not work either :(

SuzyQJax
Posts: 16
Joined: 05 Mar 2010 12:34

Re: Batch unzip

#9 Post by SuzyQJax » 06 Mar 2010 18:13

Do you have 7z.exe in the System32 directory?

SuzyQJax
Posts: 16
Joined: 05 Mar 2010 12:34

Re: Batch unzip

#10 Post by SuzyQJax » 06 Mar 2010 21:15

7z Command Description:
a Add - create a new archive, or add files to an existing archive
d Delete - remove files from an existing archive
e Extract - unarchive files
l List - display the contents of an archive
t Test - validate the integrity of an archive
u Update - overwrite existing files in an existing archive
x Extract - same as “e”, except that the files are restored to their exact original locations (if possible)

I just ran the test code and it extracted to desktop just fine.

Code: Select all

@Echo Off
:: Extracting then Expand Test.7z file from C:\Zip directory to desktop without prompt
7z.exe e "C:\Zip\test.7z"

exit

Post Reply