Created
March 6, 2017 12:36
Convert .cab to .zip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# this tool converts a .cab file to a zip file | |
# check that we have an input parameter | |
test -z "${1:-}" &&\ | |
echo "[ERROR] You need to pass a .cab file" &&\ | |
exit 1 | |
CURRENT_DIR=$(pwd) | |
TMP=$(mktemp -d -t cab) | |
FILENAME=$(echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")") | |
echo "[INFO] Extract $FILENAME to $TMP" | |
cabextract "$FILENAME" -d "$TMP" | |
# TODO: use CURRENT_DIR/$(basename "$FILENAME").zip | |
TARGET_ARCHIVE="${FILENAME%.*}".zip | |
echo "[INFO] Generate $TARGET_ARCHIVE" | |
pushd $TMP | |
zip -r "$TARGET_ARCHIVE" * | |
popd | |
echo "[INFO] Remove $TMP" | |
rm -r "$TMP" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment