-
- Shop Titanium Disc Rack
- Anodizing Supply
- About Us
- Contact Us
- 720 Rules Calculator
- FAQ
- Login
- Aluminum Anodizing supply - titanium disc and rack
- shipping worldwide!
find . -name "*.zip" -exec sh -c 'unzip -o "$0" -d "$0%/*"' {} \; If you want to extract into folders named after the zip:
for zipfile in $(find . -name "*.zip"); do dir=$(dirname "$zipfile") unzip -o "$zipfile" -d "$dir" done This breaks if filenames contain spaces or newlines. While rare for .zip files, it's safer to use:
Better version:
find . -name "*.zip" -exec unzip -o {} '*.txt' -d "$(dirname {})" \; Or to extract multiple extensions:
find . -name "*.zip" -exec sh -c ' target="$0%.zip" mkdir -p "$target" unzip -o "$0" -d "$target" ' {} \; unzip all files in subfolders linux
find . -name "*.zip" -exec sh -c 'mkdir -p "$0%.zip"; unzip -o "$0" -d "$0%.zip"' {} \; "unzip: command not found" Install unzip as shown in section 2. "warning: filename contains spaces" Use the null-separated versions ( -print0 + read -d '' or xargs -0 ). "caution: zipfile not a zip archive" Some files may have a .zip extension but not be valid zip files. Use file command to verify:
find . -name "*.zip" -exec unzip -o {} '*.txt' '*.jpg' -d "$(dirname {})" \; This extracts only matching files from each archive, ignoring everything else. Running your command twice will cause unzip to prompt for overwrite (or automatically overwrite with -o ), wasting time. To skip already-unzipped files: Option A: Use -n (never overwrite) find . -name "*.zip" -exec sh -c 'unzip -n "$0" -d "$(dirname "$0")"' {} \; Option B: Check for a marker file (e.g., .unzipped ) find . -name "*.zip" | while read zipfile; do marker="$zipfile.done" if [ ! -f "$marker" ]; then unzip -o "$zipfile" -d "$(dirname "$zipfile")" && touch "$marker" fi done Option C: Remove zip after successful extraction (dangerous but efficient) find . -name "*.zip" -exec sh -c 'unzip -o "$0" -d "$(dirname "$0")" && rm "$0"' {} \; 10. One-Liner Summary for Your Cheatsheet Here is the copy-paste-ready command that handles spaces, extracts in place, and overwrites silently: While rare for
project/ ├── data1/ │ ├── images.zip │ └── notes.zip ├── data2/ │ ├── backup.zip │ └── docs/ │ └── archive.zip └── scripts/ └── source.zip You want to extract each .zip file . For example, images.zip should be extracted inside data1/ , not in the root project/ .