Mac 像windows一样使用右键压缩文件,使用p7zip实现


具体参考 https://www.xiebruce.top/202.html
其介绍的非常详细。
只是对其中压缩的时候文件名作了一下修改,使压缩多个文件的时候加上日期作为文件的一部分。

安装 p7zip

brew install p7zip

在邮件菜单中添加快捷方式

利用 Automator 制作 快速操作。
⌘ + space -> 输入:自动操作 -> 新建文稿 -> 快速操作 -> 选择:操作>实用工具>运行shell脚本

具体设置贴图

下面 name="ZIP-"$(date "+%Y%m%d-%H%M%S") 可以修改为自定义的名称

set -e
compress_method="zip"
[[ $# = 1 ]] && name=${1##*/} || name="ZIP-"$(date "+%Y%m%d-%H%M%S")
base=${1%/*}
cd "$base"

i=2
[[ -e "$name.$compress_method" ]] && name="$name-$i"
while [[ -e "$name.$compress_method" ]]; do name="${name%??}-$((++i))"; done

echo ".DS_Store" >> .exclude_file_list
/usr/local/bin/7z a -r -t"$compress_method" ./"$name.$compress_method" "${@#"$base"/}" -xr@.exclude_file_list
rm .exclude_file_list
open -R ./"$name.$compress_method"


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM