1. Home
  2. unzip all files in subfolders linux
  3. unzip all files in subfolders linux
  1. Home
  2. unzip all files in subfolders linux
  3. unzip all files in subfolders linux

Unzip All Files In: Subfolders Linux

unzip -l archive.zip
find ... -print0 | while IFS= read -r -d '' zip; do
  if ! unzip -q "$zip" -d "$dir"; then
    echo "FAILED: $zip" >> /var/log/unzip-errors.log
  fi
done

Useful when additional per-file logic is required:

find /path/to/parent -name "*.zip" -type f | while read -r zipfile; do
    target_dir=$(dirname "$zipfile")
    unzip -o "$zipfile" -d "$target_dir"
done

The find -execdir unzip pattern is the most reliable, portable, and efficient method to unzip all files in subfolders on Linux. It handles deep nesting, preserves directory structure, and integrates seamlessly into automation scripts. For very large batches, parallel execution with GNU Parallel offers linear speedup. unzip all files in subfolders linux


Appendix A – Quick Reference Card

# Basic (overwrite)
find . -name "*.zip" -execdir unzip -o {} \;
find . -name "*.zip" -exec zipinfo {} \;

For large numbers of archives, use GNU parallel or xargs -P: GNU parallel: unzip -l archive

export LC_ALL=C
find /path/to/root -type f -iname '*.zip' -print0 |
  parallel -0 -j 4 'dir=$(dirname {}); unzip -q {} -d "$dir"'

xargs:

find /path/to/root -type f -iname '*.zip' -print0 |
  xargs -0 -n1 -P4 -I{} sh -c 'unzip -q "{}" -d "$(dirname "{}")"'

For greater flexibility (e.g., adding logging or conditional logic): Useful when additional per-file logic is required: find

find /path/to/dir -name "*.zip" -type f | while read -r zipfile; do
    targetdir="$zipfile%.zip_extracted"
    mkdir -p "$targetdir"
    unzip "$zipfile" -d "$targetdir"
    echo "Extracted: $zipfile -> $targetdir"
done