Unzip All Files In Subfolders Linux Jun 2026
How to Unzip All Files in Subfolders in Linux Managing compressed archives across nested directories is a frequent challenge for Linux system administrators and developers. If you have multiple .zip files scattered across various subfolders, extracting them manually one by one is inefficient.
If you prefer to extract every subfolder zip file into one central repository instead of their original subfolders, modify the command like this:
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.
If you want to extract each zip into its own folder (named after the zip file) to keep things organized:
The most reliable way to handle nested archives is through the . unzip all files in subfolders linux
# Enable recursive globbing in Bash shopt -s globstar for file in **/*.zip; do if [ -f "$file" ]; then unzip -d "$(dirname "$file")" "$file" fi done # Optional: Disable globstar when finished shopt -u globstar Use code with caution.
If you work with large archives, you’ve probably faced the need to unzip multiple ZIP files scattered across nested directories. Doing this manually is tedious and error‑prone. Fortunately, Linux provides powerful command‑line tools to automate this task. This article covers everything you need to know about unzipping all files in subfolders on Linux – from basic commands to advanced techniques that handle tricky filenames, preserve directory structures, and even parallelize the process.
While this one-liner is incredibly powerful, understanding how it works—and knowing when to use alternative methods—will save you time and prevent data clutter. In this guide, we will break down the best methods for unzipping files in subfolders, how to handle extracted contents, and how to avoid common pitfalls. The Ultimate One-Liner Explained Method 1: The find + unzip Command (Best for Automation)
find . -type f -name "*.zip" -exec unzip -n -d "$(dirname "{}")" "{}" \; How to Unzip All Files in Subfolders in
find . -type f -name "*.zip" -exec sh -c 'unzip -d "$(dirname "{}")" "{}"' \;
Note: This command extracts files into a new directory named after the zip file, which helps avoid clutter. Method 2: Using for Loop with find (Recursive)
Linux users often encounter situations where they need to unzip multiple files located in subfolders. This can be a tedious task, especially when dealing with a large number of files. Fortunately, Linux provides several ways to unzip all files in subfolders using the command line. In this article, we will explore the different methods to achieve this, along with examples and explanations to help you master the process.
The unzip command is a popular utility used to extract files from ZIP archives. It is widely available on most Linux distributions and can be used to unzip files in subfolders. If you want to extract each zip into
Sometimes you want each zip’s contents to be placed in a dedicated folder (named after the zip file) rather than directly inside the zip’s location. This avoids clutter and collisions.
find . -name "*.zip" -type f -exec unzip -P 'secret' {} -d {}.dir \;
shopt -s globstar for file in **/*.zip; do if [ -f "$file" ]; then unzip "$file" -d "$(dirname "$file")" fi done Use code with caution.
parallel : Spawns multiple jobs matching your CPU core count. {} : Represents the full path to the input zip file.
find . -type f -name "*.zip" -exec sh -c 'unzip -d "$(dirname "{}")" "{}" && rm "{}"' \; Use code with caution. Summary Checklist Command Formula