Unzip All Files In Subfolders Linux
shopt -s globstar for file in **/*.zip; do unzip "$file" -d "$(dirname "$file")" done shopt -u globstar Use code with caution. shopt -s globstar enables recursive directory expansion. **/*.zip matches every ZIP file at any depth level.
# Extract each ZIP into a sibling folder named ZIPNAME.extracted find . -name "*.zip" -exec unzip {} -d {}.extracted \; unzip all files in subfolders linux
Practice these commands on a test directory first. Once comfortable, you’ll wonder how you ever managed archives without them. Linux gives you the tools—now you know how to wield them. shopt -s globstar for file in **/*
-name "*.zip" filters the results to match only files ending with the .zip extension. # Extract each ZIP into a sibling folder named ZIPNAME
This is roughly the same speed as -exec ... \; but scales better if you combine it with -P for parallelism (see Method 4).
find . -name "*.zip" -print0 | xargs -0 -n1 unzip -o
| Format | Recursive extraction command | |--------|------------------------------| | .tar.gz / .tgz | find . -name "*.tar.gz" -exec tar -xzf {} \; | | .tar.bz2 | find . -name "*.tar.bz2" -exec tar -xjf {} \; | | .7z | find . -name "*.7z" -exec 7z x -y {} \; (install p7zip ) | | .gz (single file) | find . -name "*.gz" -exec gunzip {} \; |