When you have a folder containing many ZIP files, extracting them one by one can quickly become tedious. Linux makes this easy with a simple shell loop.
For example, if all the ZIP files are stored in /home/mahesh/images/, I can extract their contents into a separate all folder with:
mkdir -p /home/mahesh/images/all
for f in /home/mahesh/images/*.zip; do
[ -f "$f" ] || continue
echo "Extracting: $(basename "$f")"
unzip -j -n "$f" -d /home/mahesh/images/all
done
The -j option removes the directory structure stored inside the ZIP files, so the extracted files are placed directly in the all folder. The -n option prevents existing files from being overwritten.
This is particularly useful when dealing with student photographs or other image collections received as multiple ZIP files. Instead of manually opening each archive, a single command takes care of the entire batch.
To check the number of extracted files afterwards:
find /home/mahesh/images/all -type f | wc -l
A small shell script like this can save quite a bit of repetitive work when handling large collections of files.
