Created
November 28, 2024 00:08
-
-
Save brennanMKE/41af59acc734d56260364862ae17c2cd to your computer and use it in GitHub Desktop.
Tiny Zip
This file contains 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: $0 <folder_name>" | |
echo "Provide the name of an existing directory to be zipped." | |
} | |
run() { | |
local DIRECTORY_NAME="$1" | |
# Check if the directory exists | |
if [[ ! -d "$DIRECTORY_NAME" ]]; then | |
echo "Error: Directory '$DIRECTORY_NAME' does not exist." | |
exit 1 | |
fi | |
# Create the zip file excluding certain directories | |
zip -r "$DIRECTORY_NAME.zip" "$DIRECTORY_NAME" -x "*/.pio/*" "*/.build/*" | |
} | |
if [[ $# -ne 1 ]]; then | |
echo "Error: Missing required parameter." | |
usage | |
exit 1 | |
fi | |
run "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment