Using 7zip to extract multiple zips in multiple folders
I have a large folder tree. Let's say there are folders named A, B, C, etc. through Z. Inside each folder are a number of zip files.
I can select all the zips in a folder, right click, select 7zip, and select Extract to "*" and it works perfectly. For example if I do that with the zips in folder A, A will contain a folder for each zip with the contents of the zip inside.
What I want to do is do a search for all zip files in ALL folders (A-Z) and perform this operation all at once, such that each of the folders (A-Z) end up with folders for all the zips they contain.
What actually happens is that 7zip extracts everything to the first folder it encounters (say, A).
Does anyone know a way to do this?
You could use the windows command line. Just hit the windows logo, type cmd
and press ENTER. Then move to the directory containing the sub-directories with your zip files by typing cd c:\my\example\dir
and ENTER, if it is on another drive, type e.g. i:
and again ENTER to switch to that drive. Now, the correct path shall be shown before the cursor. Then type
for /F "usebackq" %f in (`dir /b/a:d`) do @echo %f
and ENTER. dir /b/a:d
returns one row per directory. For each of these rows, the command behind do
is executed. @echo %f
will simply write the found names on your screen, so you can safely control what would be executed if you removed @echo
. In your case, you'll need something like
for /F "usebackq" %f in (`dir /b/a:d`) do C:\APPS\7-Zip\7z.exe x .\%f\*.zip -o%f
which will for each sub-directory, call 7zip command line executable (you will need to adjust the path from C:\APPS\7-Zip\
to your system) and extract all zip files including their full path into the current sub-dir. More info on the 7zip syntax can be found at https://www.dotnetperls.com/7-zip-examples
In case you do this over and over again, you may create a simple .bat/.cmd file with above mentioned commando.