Created
January 8, 2018 17:25
-
-
Save BigNerd95/e4623a56d0d21b20cfd059508b1e5227 to your computer and use it in GitHub Desktop.
More compressed and more privacy in zip files
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 | |
| usage(){ | |
| echo "Usage:" | |
| echo "$0 FOLDER_TO_COMPRESS [-e] [-v]" | |
| echo "-e: encrypt" | |
| echo "-v: verbose" | |
| } | |
| compress(){ | |
| local TMP_ZIP="${FOLDER_TO_COMPRESS}.zip" | |
| zip $VERBOSE -0 -r $TMP_ZIP "${FOLDER_TO_COMPRESS}" && \ | |
| zip $VERBOSE -9 $ENCRYPT $ARCHIVE_NAME $TMP_ZIP && \ | |
| rm "$TMP_ZIP" | |
| } | |
| main(){ | |
| FOLDER_TO_COMPRESS=$1 | |
| ARCHIVE_NAME="${FOLDER_TO_COMPRESS}_archive.zip" | |
| ENCRYPT="" | |
| VERBOSE="-q" | |
| if [ -z "$FOLDER_TO_COMPRESS" ] | |
| then | |
| usage | |
| exit 1 | |
| fi | |
| shift | |
| while test $# -gt 0 | |
| do | |
| case "$1" in | |
| -e) | |
| ENCRYPT="-e" | |
| ;; | |
| -v) | |
| VERBOSE="" | |
| ;; | |
| *) | |
| echo "Unknown argument $1" | |
| echo | |
| usage | |
| exit 1 | |
| ;; | |
| esac | |
| shift | |
| done | |
| compress | |
| echo "Archive: $ARCHIVE_NAME" | |
| } | |
| main $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment