Batch unzip
Moderator: DosItHelp
Batch unzip
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
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
Re: Batch unzip
Current dir? Use %cd% var:d_a_r_k wrote:directory from where the batch file has been executed
Code: Select all
7z e archive.zip -o"%cd%" *.* -r
Re: Batch unzip
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?
Re: Batch unzip
Quite so.
Code: Select all
7z e "d:\full path\archive.zip" -o"%cd%" *.* -r
Re: Batch unzip
Unfortunately I still get the same error, it cannot find the specified archive.
Re: Batch unzip
Do you have 7z.exe in the System32 directory?
Re: Batch unzip
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.
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