Preface
Suddenly one day, when I was uploading resources to CxDrive, I needed to package each subfolder into a zip, and it was really too tiring to do it manually one by one, so why not write a script for this kind of thing?
Tutorial
- First, we search for Automator through Spotlight and open it.

- Add a new Quick Action

- Search Run Shell

- Select the corresponding configuration, workflow purpose: files or folders , location:Finder

- Drag the Run Shell Script to the right and type in the command 👇🏻
for f in "$@"; do
dn="$(dirname "$f")"
bn="$(basename "$f")"
cd "$dn" || exit
if [[ ! -e "$bn.zip" ]]; then
ditto -c -k --sequesterRsrc --keepParent "$f" "$bn.zip"
else
n=2
for i in $bn *.zip; do
if [[ "$bn $n.zip" == "$i" ]]; then
n="$(( n + 1 ))"
fi
done
ditto -c -k --sequesterRsrc --keepParent "$f" "$bn $n.zip"
fi
done
afplay /System/Library/Sounds/Purr.aiff
Demo
Conclusion
Don't do repetitive things, we only need to be responsible for innovation.