Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Merges multiple ZIP files into a single ZIP
#!/bin/bash
OUT_NAME="$1"
shift
IN_NAMES="$@"
TMP_DIR=$(mktemp -d)
# Unzip each input ZIP
for IN_NAME in $IN_NAMES; do
unzip -n "$IN_NAME" -d "$TMP_DIR"
done
# ZIP all contents of uncompressed output into the temporary directory
(cd "$TMP_DIR"; zip -r "$OUT_NAME" *)
# Move output ZIP to final location
mv "$TMP_DIR"/"$OUT_NAME" "$OUT_NAME"
# Check contents of output ZIP
unzip -l "$OUT_NAME"
# Clean up all temporary files
rm -r "$TMP_DIR"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.