Unzip All Files In Subfolders — Linux
Running your command twice will cause unzip to prompt for overwrite (or automatically overwrite with -o), wasting time. To skip already-unzipped files:
find . -name "*.zip" -type f -exec unzip -j {} "*.txt" -d {}.text_files \;
-j jams paths (no directory structure inside ZIP), "*.txt" selects only text files.
For thousands of ZIP files, use GNU Parallel: unzip all files in subfolders linux
find /path/to/parent -name "*.zip" -type f | parallel 'unzip -o {} -d //'
If you are using a standard Bash shell and don't have complex filenames, you can use the built-in globstar feature.
The Command:
unzip -d ./output_folder **/*.zip
Breakdown:
Note: If you get an "argument list too long" error, use Method 1 instead. Running your command twice will cause unzip to
| Method | Best for | Command length |
|--------|----------|----------------|
| find -exec | Most users, moderate file count | Short |
| find + xargs | Thousands of ZIPs | Medium |
| Bash loop | Readability in scripts | Long |
| Globstar | Interactive use with bash 4+ | Short |
| Recursive loop | ZIPs inside ZIPs | Medium |
A user has a parent directory containing multiple subfolders (depth ≥ 1). Each subfolder may contain zero, one, or several .zip files. The objective is to extract every .zip file in its own subfolder (preserving original directory structure) without manually navigating into each folder. -j jams paths (no directory structure inside ZIP), "*