Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to batch the "Extract Here..." command on a complete folder. Every type of archive should be unzipped into the current folder with the name of the archive file. I have found some BATCH scripts for just *.zip, but I don't care what kind of archive it is, as long as my archiver can open it.

Does anyone know what kind of archiver has such a batching funcionality? I can't seem to find it in 7-zip or winrar.

In pseudo:

Given folder x
foreach archiveFile in x or descendant of x
unzip archiveFile.extension >> "folder of archiveFile/archiveFile"

Update
I have tried the following for only zip files:

dir /s /b *.zip > allzips.txt
for /F %%x in (allzips.txt) do unzip %%x

Where unzip is still an unknown function.

share|improve this question
    
Can you paste your code for the .zip here and I will adapt it. – William Hilsum Aug 26 '11 at 13:40
    
@William There you go. – Marnix Aug 26 '11 at 14:36
up vote 5 down vote accepted

EDIT Given: Using batch script.

You may wish to use a third party zip tool (highly recommend 7-ZIP command line version called 7z.exe) to accomplish this.

with 7z, the syntax is as follows:

7z <command> [<switch>...] <base_archive_name> [<arguments>...]

To extract the command would be:

7z e file.zip -y

the -y switch assume "Yes" answer to any questions that may come up during extraction such as overwrite requests.

So your command will read

CD "C:\Location\Of\ZipFiles"
FOR /F "USEBACKQ tokens=*" %%F IN (`DIR /b *.zip`) DO (7z e "%%F" -y)

If you want to output them into a different location, you can use the -o switch and specify the directory:

7z e "%%F" -y -oC:\Some\Other\Folder\

EDIT:

To perform the extract with full paths and specifying all ZIP archives only, use this:

7z x -tzip "C:\Location\of\zips\*"

Or even nutzier... all ZIP files on C: drive:

7z x -r -tzip "C:\*"

EDIT2:

Making it compatible with your output file, this:

dir /s /b *.zip > allzips.txt
for /F %%x in (allzips.txt) do (7z x -tzip "%%x")
share|improve this answer
    
I would like to maintain the folder and output them at the location itself. Shouldn't I use the x instead of e? And: This is still for zip files only. Isn't there a way to just say: all archive-kind-of-files? – Marnix Aug 26 '11 at 14:33
    
So you want to pull ALL ZIP FILES from anywhere on the drive and tell them to extract where they sit into a folder named the same as the zip file? And no in 7z the extract option is 'e' – Mechaflash Aug 26 '11 at 17:42
    
You can use 'x' instead of 'e' to preserve the full path yes. My mistake. – Mechaflash Aug 26 '11 at 17:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .