Unzip All Files In Subfolders Linux -

Directory tree before:

data/
├── projectA/
│   ├── images.zip
│   └── notes.txt
├── projectB/
│   └── backup.zip
└── archive.zip

After running the command:

data/
├── projectA/
│   ├── images.zip
│   ├── image1.png      (extracted)
│   ├── image2.png
│   └── notes.txt
├── projectB/
│   ├── backup.zip
│   └── data.csv        (extracted)
└── archive.zip
    ├── readme.txt      (extracted in data/)
    └── script.sh

The for loop splits output. Use find ... -exec or xargs instead. unzip all files in subfolders linux


For large numbers of archives, use GNU parallel or xargs -P: GNU parallel: After running the command: data/ ├── projectA/ │

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 "{}")"'