Unzip All Files In Subfolders Linux [2025-2026]
This breaks if filenames contain spaces or newlines. While rare for .zip files, it's safer to use:
src="/path/to/root" dst="/path/to/extracted" find "$src" -type f -iname '*.zip' -print0 | while IFS= read -r -d '' zip; do rel="$zip#$src/" reldir="$(dirname "$rel")" mkdir -p "$dst/$reldir" unzip -q "$zip" -d "$dst/$reldir" done
Managing files across multiple subdirectories is a common task in Linux, and while the unzip command is great for single archives, it doesn't natively handle recursive folder structures. unzip all files in subfolders linux
if [ "$DRY_RUN" = false ] && [ ! -d "$DEST_BASE" ]; then mkdir -p "$DEST_BASE" fi
find . -name "*.zip" -type f -exec unzip -o {} -d {}.dir \; This breaks if filenames contain spaces or newlines
while [[ $# -gt 0 ]]; do case $1 in --dry-run) DRY_RUN=true; shift ;; --help) echo "Usage: $0 [source_dir] [dest_base] [--dry-run]"; exit 0 ;; *) break ;; esac done
sudo apt install parallel # or equivalent -d "$DEST_BASE" ]; then mkdir -p "$DEST_BASE" fi find
find . -name "*.zip" -execdir unzip {} \;
Sometimes, you want to extract all nested zip files into one single, centralized location.