How do I unzip all files in a folder using 7-zip in batch?
Just to add up on Gabor's answer.
My default installation folder was C:\Program Files (x86)\7-Zip
so I'm going to go from there.
Here is the link to download 7zip.
I wanted to unzip every zip file in a directory into multiple folder. however the e
in the previous answer export everything in the directory.
Here is for the "normal" unzip creating a folder per zip file unzipped:
"C:\Program Files (x86)\7-Zip\7z.exe" x *.zip
And to have a full details of what you can do with 7z.exe use the --help
:
"C:\Program Files (x86)\7-Zip\7z.exe" --help
Here is its output:
Usage: 7z <command> [<switches>...] <archive_name> [<file_names>...]
[<@listfiles...>]
<Commands>
a: Add files to archive
b: Benchmark
d: Delete files from archive
e: Extract files from archive (without using directory names)
l: List contents of archive
t: Test integrity of archive
u: Update files to archive
x: eXtract files with full paths
<Switches>
-ai[r[-|0]]{@listfile|!wildcard}: Include archives
-ax[r[-|0]]{@listfile|!wildcard}: eXclude archives
-bd: Disable percentage indicator
-i[r[-|0]]{@listfile|!wildcard}: Include filenames
-m{Parameters}: set compression Method
-o{Directory}: set Output directory
-p{Password}: set Password
-r[-|0]: Recurse subdirectories
-scs{UTF-8 | WIN | DOS}: set charset for list files
-sfx[{name}]: Create SFX archive
-si[{name}]: read data from stdin
-slt: show technical information for l (List) command
-so: write data to stdout
-ssc[-]: set sensitive case mode
-ssw: compress shared files
-t{Type}: Set type of archive
-u[-][p#][q#][r#][x#][y#][z#][!newArchiveName]: Update options
-v{Size}[b|k|m|g]: Create volumes
-w[{path}]: assign Work directory. Empty path means a temporary directory
-x[r[-|0]]]{@listfile|!wildcard}: eXclude filenames
-y: assume Yes on all queries
This will unzip all zip files in the current folder(into the same folder), assuming you have installed 7zip into C:\Program Files\7-Zip
location.
If you have added your 7zip folder into the path, you can just enter 7z instead of the fullpath
"C:\Program Files\7-Zip\7z.exe" e *.zip
You can use x instead of e this will allow you to extract each zip file in folder with zip file name.
"C:\Program Files\7-Zip\7z.exe" x *.zip
example you have list of zip file
file001.zip
file002.zip
fileXXX.zip
will extract into /file001 , /file002, /fileXXX in same folder where zip file located.
I am not sure about the OP's intent but I think it is a good idea to have a subfolder for each .zip file, so that files with the same name will not get overwritten. (Just like when you drag and drop with the right mouse button multiple .zip files and select 7-Zip > Extract Files ... from the local menu.)
For this I use this at the command line:
for /f "usebackq delims=" %f in ( `dir /b /s *.zip` ) do 7z x "%f" -o"%~pf%~nf"
If you do not have 7-Zip's program folder in your PATH
environment variable, you need to write its full path. On x86 Windows or x64 Windows with x64 7-Zip:
for /f "usebackq delims=" %f in ( `dir /b /s *.zip` ) do "C:\Program Files\7-Zip\7z.exe" x "%f" -o"%~pf%~nf"
On x64 Windows with x86 7-Zip:
for /f "usebackq delims=" %f in ( `dir /b /s *.zip` ) do "C:\Program Files (x86)\7-Zip\7z.exe" x "%f" -o"%~pf%~nf"
Note: cmd substitutes %~pf
with the path (actually directory name, including a backslash at the end) of the variable %f
, and %~nf
with the filename (without file extension).