I had problem running the script from Windows Vista. When I ran the code nothing happend. I needed to be administrator to be able to run the script. When I right clicked on the .bat file and "run as administrator" it didn't work because it for some reason started in the system32 folder (if I remember correctly). To solve this simply use the Windows Environment variable (explained here: Windows Environment Variables) %~dp0 to switch back to the directory that the script was run from.
@echo on
cd %~dp0
FOR /D /r %%F in ("*") DO (
pushd %CD%
cd %%F
FOR %%X in (*.rar *.zip) DO (
"C:\Program Files\7-zip\7z.exe" x %%X
)
popd
)
Make sure no *.rar or *.zip files are at the same level as the script. They should be one level down.
find . -name "*.zip" | while read filename; do unzip -o -d "`dirname "$filename"`" "$filename"; done;
Starts a recursive search at the current directory, finds all files ending in .zip, then pipes that into a loop. For every file it finds, it runs an unzip command on the file with the output shunted to the file's directory.
The answers above work, however, if you are running Windows 64-bit and 7-Zip 32-bit, the correct path is C:\Program Files (x86)\7-Zip for 7-Zip. Below is the script that worked for me.
@echo on
cd %~dp0
FOR /D /r %%F in ("*") DO ( pushd %CD% cd %%F
FOR %%X in (*.rar *.zip) DO (
"C:\Program Files (x86)\7-zip\7z.exe" x %%X
)
popd
)
Firstly, install 7-zip.
Create a
bat
file in the root of the directory containing many subdirectories with archives inside. Then paste the following in:Launch the bat, and all rar's/zips will be extracted into the folder they are contained in.
How does this work?
Hope this is useful to someone.
I had problem running the script from Windows Vista. When I ran the code nothing happend. I needed to be administrator to be able to run the script. When I right clicked on the .bat file and "run as administrator" it didn't work because it for some reason started in the system32 folder (if I remember correctly). To solve this simply use the Windows Environment variable (explained here: Windows Environment Variables) %~dp0 to switch back to the directory that the script was run from.
Make sure no *.rar or *.zip files are at the same level as the script. They should be one level down.
I hope this comment helped someone.
Starts a recursive search at the current directory, finds all files ending in .zip, then pipes that into a loop. For every file it finds, it runs an unzip command on the file with the output shunted to the file's directory.
The answers above work, however, if you are running
Windows 64-bit
and7-Zip 32-bit
, the correct path isC:\Program Files (x86)\7-Zip
for 7-Zip. Below is the script that worked for me.