Skip to content

Commit

Permalink
Modify encrypt_zip to also accept directories
Browse files Browse the repository at this point in the history
  • Loading branch information
GMadorell committed May 20, 2024
1 parent b6e794c commit 43508c9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -457,11 +457,14 @@ function encrypt_zip {
if [ -z "$1" ]; then
echo "Usage: encrypt_zip <path/file_name>"
else
if [ -f "$1" ] ; then
zip -P $DOCUMENTATION_PW "$1.zip" $1
rm $1
if [ -f "$1" ]; then
zip -P $DOCUMENTATION_PW "$1.zip" "$1"
rm "$1"
elif [ -d "$1" ]; then
zip -r -P $DOCUMENTATION_PW "$1.zip" "$1"
rm -r "$1"
else
echo "'$1' - file does not exist"
echo "'$1' - file or directory does not exist"
fi
fi
}
Expand Down

0 comments on commit 43508c9

Please sign in to comment.