Unzip All Files In Subfolders | Linux

if [[ "$*" == "--overwrite" ]]; then OVERWRITE="-o" else OVERWRITE="-n" fi

#!/bin/bash # Usage: ./unzip-all.sh [directory] [--overwrite] [--delete] SEARCH_DIR="$1:-." OVERWRITE="" DELETE_AFTER=false unzip all files in subfolders linux

find "$SEARCH_DIR" -name "*.zip" -type f -print0 | while IFS= read -r -d '' zip; do target=$(dirname "$zip") echo "Extracting: $zip -> $target" unzip $OVERWRITE -q "$zip" -d "$target" if [ $? -eq 0 ] && [ "$DELETE_AFTER" = true ]; then rm "$zip" echo "Deleted: $zip" fi done if [[ "$*" == "--overwrite" ]]; then OVERWRITE="-o"

If you’ve ever downloaded a large dataset, a batch of game mods, or a collection of ebooks on Linux, you’ve likely encountered the same frustrating scenario: a parent folder filled with dozens (or hundreds) of subfolders, each containing one or more .zip archives. Opening each subfolder, right-clicking, and extracting manually is tedious, error-prone, and completely against the Linux philosophy of automation. while find

while find . -name "*.zip" -type f | grep -q .; do find . -name "*.zip" -type f -exec unzip -o {} -d {}/.. \; find . -name "*.zip" -type f -delete # optional: remove original zip after extraction done This repeats until every nested ZIP is fully expanded. Remove the -delete line if you want to keep the original archives. If you have enabled globstar in bash, you can avoid find :

find . -name "*.zip" -type f -print0 | xargs -0 -I {} sh -c 'unzip -o "{}" -d "$(dirname "{}")"' The -exec option runs unzip once per file. xargs groups multiple file paths into a single command, reducing process overhead. The -print0 and -0 handle filenames with spaces or special characters safely. Method 3: Pure Bash Loop (Most Readable) If you prefer clarity over brevity:

find . -name "*.zip" -type f -print0 | while IFS= read -r -d '' zipfile; do unzip -o "$zipfile" -d "$(dirname "$zipfile")" done Sometimes you don’t want to preserve the subfolder structure—you want all extracted files dumped into one folder (e.g., ~/extracted ):

4 thoughts on “IQ Dungeon Solutions Walkthrough [All 300 Levels]

Leave a Reply

Your email address will not be published. Required fields are marked *