How do I extract multiple archives in contained in subdirectories in a folder, outputting the results back into the folders where the archives are.
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 this works?
For loop to loop through all folders in the current directory, and put the path into a variable %%F.
Put the current directory that we are in into memory.
Set the folder from variable %%F as the current directory.
For all the rar and zip files in the current folder, do:
Run 7-zip on the files. Quotes are needed around %%X because some file names have spaces in them.
Return to the previous directory that we previously stored in the memory.
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.
FYI, if you have a Windows 7 64 bit OS, the correct path is "Program Files (x86)" for 7zip. Below is the script that worked for me.
Thanks! To extract also zips in zips you can try this.
It should be extended with error checking to avoid deleting files that were not really unzipped. I am so rookie that I am not able to do that..
Could someone tell what does mean