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

青春壹個敷衍的年華 提交于 2020-01-07 02:37:14

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!