Skip to content

Instantly share code, notes, and snippets.

@brennanMKE
Created November 28, 2024 00:08
Show Gist options
  • Save brennanMKE/41af59acc734d56260364862ae17c2cd to your computer and use it in GitHub Desktop.
Save brennanMKE/41af59acc734d56260364862ae17c2cd to your computer and use it in GitHub Desktop.
Tiny Zip
#!/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