-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathzip.sh
More file actions
executable file
·37 lines (31 loc) · 1.1 KB
/
Copy pathzip.sh
File metadata and controls
executable file
·37 lines (31 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# Get the directory where this script is located
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
FOLDER_NAME="$(basename "$DIR")"
ZIP_FILE="$DIR/${FOLDER_NAME}.zip"
# List of files and folders to ignore (patterns relative to the folder)
IGNORE_LIST=(
"${FOLDER_NAME}.zip" # the zip file itself
".git/*" # ignore the .git folder (if present)
"node_modules/*" # ignore node_modules folder
"tmp/*" # ignore tmp folder
"*.log" # ignore log files
"README.MD"
"zip.sh"
)
# Remove any existing zip file with the same name to avoid including it in the new archive
if [ -f "$ZIP_FILE" ]; then
echo "Removing existing zip file: $ZIP_FILE"
rm "$ZIP_FILE"
fi
echo "Creating zip archive of $DIR..."
# Change to the target directory so that the zip archive paths are relative
cd "$DIR"
# Build the exclude arguments for the zip command
EXCLUDES=()
for pattern in "${IGNORE_LIST[@]}"; do
EXCLUDES+=(-x "$pattern")
done
# Create the zip archive including the excludes
zip -r "$ZIP_FILE" . "${EXCLUDES[@]}"
echo "Zip archive created: $ZIP_FILE"