安全清倒废纸篓(AppleScript)

on run {input, parameters}
set title to "安全清倒废纸篓"
set trashIsEmptyMessage to "废纸篓是空的,不需要清空。"
set willDeleteMessage to "请选择清空方式?"
set secureDeleteAction to "安全清倒废纸篓"
set secureDeleteActionTerminal to "安全清倒废纸篓(详细)"
set cancelAction to "取消"
set okAction to "好"
set errorMessage to "发生错误:"
set finishMessage to "已经安全清倒废纸篓。"
set srmCommand to "sudo srm -rfsz /Volumes/*/.Trashes ~/.Trash"
set srmVerboseCommand to "sudo srm -rfvsz /Volumes/*/.Trashes ~/.Trash" tell application "Finder"
set trashCount to count of items in the trash
if trashCount = 0 then
beep
activate
display dialog trashIsEmptyMessage buttons {okAction} default button okAction with title title
return input
end if
try
beep
activate
set dialog to display dialog willDeleteMessage buttons {secureDeleteActionTerminal, secureDeleteAction, cancelAction} default button cancelAction with title title
on error
return input
end try
set interface to button returned of dialog
end tell if interface is cancelAction then
return input
end if if interface is secureDeleteAction then
tell application "Finder"
try
do shell script srmCommand with administrator privileges
activate
display dialog finishMessage buttons {okAction} with title title
on error errmsg
beep
activate
display dialog errorMessage & errmsg buttons {okAction} with title title
end try
end tell
else if interface is secureDeleteActionTerminal then
tell application "Terminal"
launch
delay 0.2
activate
do script srmVerboseCommand
end tell
--else if interface is deleteAction then
-- tell application "Finder"
-- empty the trash
-- end tell
end if return input
end run

Finder - 服务 -  安全清倒废纸篓

强行删除(AppleScript)

on run {input, parameters}
set title to "强行删除"
set willDeleteMessage to "此操作将不经过废纸篓*直接删除*选中的文件:"
set fileCountUnitMessage to "个"
set deleteAction to "删除"
set secureDeleteAction to "安全删除"
set cancelAction to "取消"
set okAction to "好"
set finishedMessage to "操作完成"
set errorMessage to "删除期间发生了错误:"
set fileCountZeroMessage to "未选择任何文件或文件夹。"
set deleteCommand to "sudo rm -rf"
set secureDeleteCommand to "sudo srm -rfsz" set fileCount to the count of input
if fileCount = 0 then
beep
activate
display dialog fileCountZeroMessage buttons {okAction} default button okAction with title title
return input
end if set theFiles to ""
set theFilesMsg to ""
repeat with theFile in input
set p to quoted form of (POSIX path of theFile)
set theFiles to theFiles & " " & p
set theFilesMsg to theFilesMsg & "
" & p
end repeat tell application "Finder"
try
beep
activate
set msg to willDeleteMessage & (fileCount as string) & fileCountUnitMessage & theFilesMsg
set dialog to display dialog msg buttons {secureDeleteAction, deleteAction, cancelAction} default button cancelAction with title title
on error
return input
end try
set interface to button returned of dialog
end tell if interface is cancelAction then
return input
end if if interface is deleteAction then
try
do shell script deleteCommand & theFiles with administrator privileges
activate
tell application "Finder" to display dialog finishedMessage buttons {okAction} with title title
on error errmsg
beep
activate
tell application "Finder" to display dialog errorMessage & errmsg buttons {okAction} with title title
end try
else if interface is secureDeleteAction then
try
do shell script secureDeleteCommand & theFiles with administrator privileges
activate
tell application "Finder" to display dialog finishedMessage buttons {okAction} with title title
on error errmsg
beep
activate
tell application "Finder" to display dialog errorMessage & errmsg buttons {okAction} with title title
end try
end if return input
end run

在Finder中选择要删除的文件,右键 - 服务 - 强行删除

显示隐藏文件(Run Shell Script)

STATUS=`defaults read com.apple.finder AppleShowAllFiles`
if [ $STATUS == YES ];
then
defaults write com.apple.finder AppleShowAllFiles NO
else
defaults write com.apple.finder AppleShowAllFiles YES
fi
killall Finder

Finder - 服务 - 显示隐藏文件

打包下载地址:

http://pan.baidu.com/s/1eQsG2PW

mac实用脚本的更多相关文章

  1. QL Server 实用脚本

    use MyFirstDB; -- 主要内容 -- SQL Server 实用脚本 -- 1.case语句 -- 2.子查询 -- 3.连接查询 -- 4.脚本变量与流程控制(选择与循环等) -- 5 ...

  2. Mac实用技巧之:访达/Finder

    更多Mac实用技巧系列文章请访问我的博客:Mac实用技巧系列文章 Finder就相当于windows XP系统的『我的电脑』或win7/win10系统里的『计算机』(打开后叫资源管理器),find是查 ...

  3. 8 个 Python 实用脚本,赶紧收藏备用!

    脚本写的好,下班下得早!程序员的日常工作除了编写程序代码,还不可避免地需要处理相关的测试和验证工作. 例如,访问某个网站一直不通,需要确定此地址是否可访问,服务器返回什么,进而确定问题在于什么.完成这 ...

  4. Python 实用脚本

    Python 实用脚本 脚本写的好,下班下得早!程序员的日常工作除了编写程序代码,还不可避免地需要处理相关的测试和验证工作. 例如,访问某个网站一直不通,需要确定此地址是否可访问,服务器返回什么,进而 ...

  5. 精确报告Linux内存使用情况实用脚本:ps_mem

    精确报告Linux内存使用情况实用脚本:ps_mem 2019-09-06 12:45 ps_mem内存工具 ps_mem 是一个可以帮助我们精确获取 Linux 中各个程序核心内存使用情况的简单 p ...

  6. Unity3D研究院之在MAC上脚本XlsxWriter写入Excel .xlsx格式

    原地址:http://www.xuanyusong.com/archives/3011 以前找了很久可以跨平台支持读写Excel的工具,我也试了很多种DLL.可在Windows上各个完美支持,可是在M ...

  7. macOS 自动修改mac地址脚本

    介于 某公众号提供了通过修改mac地址来链接BUPT_mobile 的推送,上网上查了一下咋写脚本,实现一键修改mac地址的功能 网上有自动修改mac地址的程序,但是很坑爹的要收费,所以不如自力更生写 ...

  8. Mac实用技巧

    1. 程序员Mac新装机必备 Mac很玄这个大家都承认,但是鄙人觉得程序员用Mac才能真正发挥它的功效.下面就说说我的Mac使用: 基本编程软件:xcode,这个东西不仅仅是对mac的界面程序开发有用 ...

  9. 8 个 Python 实用脚本,【速】收藏备用!

    脚本写的好,下班下得早!程序员的日常工作除了编写程序代码,还不可避免地需要处理相关的测试和验证工作. 例如,访问某个网站一直不通,需要确定此地址是否可访问,服务器返回什么,进而确定问题在于什么.完成这 ...

随机推荐

  1. rgba透明的兼容处理

    background-color: rgba(0, 0, 0, .6);filter: progid:DXImageTransform.Microsoft.gradient(startColorstr ...

  2. Json模块的详细介绍(序列化)

    什么叫序列化——将原本的字典.列表等内容转换成一个字符串的过程就叫做序列化. 比如,我们在python代码中计算的一个数据需要给另外一段程序使用,那我们怎么给? 现在我们能想到的方法就是存在文件里,然 ...

  3. (转)fiddler使用简介--其一

    原文地址:https://www.cnblogs.com/miantest/p/7289694.html Fiddler基础知识 Fiddler是强大的抓包工具,它的原理是以web代理服务器的形式进行 ...

  4. 【读书笔记】Java核心技术-基础知识-反射

    在网页中运行Java程序称为applet. 反射 这项功能被大量地应用于JavaBeans中,它是Java组件的体系结构. 能够分析类能力的程序称为反射(reflective).反射机制的功能及其强大 ...

  5. ajax跨域资源共享

    一.同域发送数据 略 二.跨域发送数据 1.存在的问题 1.什么是同源策略 同源策略阻止从一个域名上加载的脚本获取或操作另一个域名上的文档属性.也就是说,受到请求的 URL 的域名必须与当前 Web ...

  6. MySQL 数据库怎样把一个表的数据插入到另一个表

         web开发中,我们经常需要将一个表的数据插入到另外一个表,有时还需要指定导入字段,设置只需要导入目标表中不存在的记录,虽然这些都可以在程序中拆分成简单sql来实现,但是用一个sql的话,会节 ...

  7. 011_用eclipse打开hadoop1.2.1源码出现The method getSplits(JobConf, int) is undefined for the type Object错误

    出现的错误截图: 此时Eclipse使用的jdk1.8,将编译环境改成jdk1.7就行了,解决. 没问题了. 下面观点是参考如下网址,未经验证.参考:http://blog.csdn.net/onei ...

  8. NoSQL数据库memcache和redis区别

    在web后台发开面试中,经常会被问道memcache和redis的区别和使用情况. 其中memcache和redis都是基于内存存储的缓存系统,存储形式key--value键值对的形式. 区别: 1. ...

  9. axios拦截器/http

    Interceptors //处理请求或响应之前拦截请求或响应. //添加一个请求拦截器 axios.interceptors.request.use(function (config) { //在请 ...

  10. 为多个文件夹下的C源代码编写Makefile文件

    上一篇文章写了如何为在同一个文件夹下的C源代码,本篇文章为多个文件夹下的C源代码编写Makefile文件. 建立两个文件夹,分别为abs与src.其最终目录结构如下: 1 $ ls * 2 jun.c ...