Skip to content

Instantly share code, notes, and snippets.

@zty5678
Created July 2, 2024 14:10
Show Gist options
  • Select an option

  • Save zty5678/373f97360e333e7b4c524ce5973b98e0 to your computer and use it in GitHub Desktop.

Select an option

Save zty5678/373f97360e333e7b4c524ce5973b98e0 to your computer and use it in GitHub Desktop.
clean .DS_Store and __MACOSX in zip file on Mac
#!/bin/bash
for f in "$@"
do
# 获取文件类型,以确保是 Zip 压缩文件
fileType=$(file -bI "$f")
echo "fileType= $fileType"
if [[ $fileType =~ application/zip.* ]]; then
# 删除 __MACOSX 与 .DS_Store 文件
zip -d "$f" \*__MACOSX\* || true
zip -d "$f" \*.DS_Store\* || true
fi
done
osascript -e "display notification \"zip文件清理成功\" with title \"提示\""
@zty5678
Copy link
Author

zty5678 commented Jul 2, 2024

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment