问题
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
回答1:
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.
回答2:
Windows version:
for /r "C:\Some\Directory" %f in (*.zip) do unzip "%f" -d "%~dpf"
Warning: Completely untested.
References:
- http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/for.mspx
- http://www.info-zip.org/mans/unzip.html
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.
来源:https://stackoverflow.com/questions/13895624/script-to-extract-zip-files-in-seperate-folders-to-their-own-folders