polerto
polerto

Reputation: 1790

Script to extract zip files in seperate folders to their own folders

I have hundreds of folders each containing a zip file. I would like to extract each zip file to where they are located. Is there a simple trick or script to do this?

EDIT:

Each folder is under the same parent folder. So the hierarchy is as the following:

PARENT FOLDER
-SubFolder1
--somefile.zip
-Subfolder2
--somefile.zip
...
-SubfolderN
--somefile.zip

Upvotes: 0

Views: 2398

Answers (2)

melpomene
melpomene

Reputation: 85757

Windows version:

for /r "C:\Some\Directory" %f in (*.zip) do unzip "%f" -d "%~dpf"

Warning: Completely untested.

References:

I think with 7-zip it would be

for /r "C:\Some\Directory" %f in (*.zip) do 7z x -o "%~dpf" "%f"

but that's even untesteder.

Upvotes: 1

Max
Max

Reputation: 773

Under unix you could use something like

find <dir> -iname '*.zip' -execdir unzip {} \;

The program find traverses <dir> recursively and on every .zip file it finds it will change to that files directory and executes unzip on it.

Upvotes: 1

Related Questions