As the title says, I would like to know how to be able to unzip multiple "7z" files at once, and have the contents of the .7z files placed in a folder (in the same directory as the ".7z") with the same name as the .7z file. Also, is it possible to automatically create the folders if they don't exist?
Asked
Active
Viewed 1,697 times
0
-
Best and working solution can be found in below link - https://superuser.com/questions/371384/extract-all-zips-in-a-directory-incl-subfolders-with-a-bat-file-or-dos-comm/371581#371581?newreg=bcf9321f6ec34563a26396cba4388ccf – Archana Deshpande Apr 14 '23 at 06:35
1 Answers
1
It doesn't seem like there is a commandline option so you will have to use some kind of loop. An example could look like this:
#!/bin/bash
for i in *.7z do
dirName=${i/\.7z/}
mkdir "$dirName"
7za x -o"$dirName" $i
done
Seth
- 9,000
- 1
- 19
- 34
-
Quote the `"$dirname"` else it will do mess in case of spaces... `;-)`... maybe better `for i in *.7z` to avoid to parse ls ( [trdr;](http://unix.stackexchange.com/q/128985/66388) other problems with newlines and special characters.) – Hastur Oct 14 '16 at 09:50
-
-
It's full of people that persist to use windows out there... `:-D` and that continue to send you files... – Hastur Oct 14 '16 at 09:56