ubuntu extract each archive to folder

+6

To extract multiple archives (ZIP, 7z, tar.gz) in Ubuntu, each into its own dedicated folder named after the file, 

use a terminal loop. For zip files, use for f in *.zip; do unzip "$f" -d "${f%.*}"; done. For 7z files, use for file in *.7z; do 7z x -o"${file%.7z}" "$file"; done. 

Ask Ubuntu +3

Methods for Extracting Archives to Separate Folders

ZIP Files (Loop Method):
This command iterates through all .zip files in the current directory and creates a new directory for each, named by stripping the .zip extension.

bash

for i in *.zip; do unzip "$i" -d "${i%%.zip}"; done 

7z Files (Loop Method):
For 7z archives, use this loop to extract them into folders.

bash

for file in *.7z; do 7z x -o"${file%.7z}" "$file"; done 

Using find for Subdirectories:
To find all zip files in the current directory and subdirectories, use:

bash

find . -name '*.zip' -exec sh -c 'unzip -d "${1%.*}" "$1"' _ {} \; 

Arch

