首先贴图,我平时使用的一些规则,然后说一些平常有用的一些规则,及使用场景。
以上几个规则,都比较简单,简单说说规则3,规则3是配合Mac自带的Automator实现,实现效果如下(折腾半天也没有弄好视频):
以下是具体实现步骤:
步骤一:使用Automator创建一个工作流
选择工作流类型
1
2
3
重点是AppleScript脚本,主要通过脚本实现新建同名文件夹,并且移动APP安装包到新建的目录下,具体实现如下:
on run {input, parameters}
if (count of input) < 3 then return
--获取过来时间
set filterTime to (item -2 of input) as number
--获取目标目录
set targetFolder to (item -1 of input)
--待处理文件
set input to items 1 through -3 of input
set output to {}
repeat with temp in the input -- 循环遍历没改安装包文件
set anItem to temp as text
set oneminutes to (current date) - filterTime * minutes
tell application "System Events" to tell disk item anItem
set relTargetPath to targetFolder
--指定目录
set theContainer to targetFolder
set {theName, theExtension, theFileDate} to {name, name extension, creation date}
end tell
--过滤创建时间
if theFileDate > oneminutes then
if theExtension is in {"app", "dmg"} then
--软件名称
set theName to text 1 thru -((count theExtension) + 2) of theName -- the name part
--判断是否存在同名目录
tell application "Finder" to set targetPathFileExists to exists folder ((targetFolder as text) & theName)
--display dialog ((targetFolder & theName) as text)
--display dialog ((targetPathFileExists) as text)
if targetPathFileExists is true then
set tempVar to display dialog "文件夹[" & theName & "] 已存在,是移动" buttons {"是", "否"}
set theButtonPressed to button returned of tempVar
if theButtonPressed = "是" then
tell application "Finder"
move temp to (targetFolder as text) & theName
display notification "成功移动到:" & POSIX path of ((targetFolder as text) & theName) with title ("文件: " & theName as text)
end tell
end if
else
tell application "Finder"
make new folder at folder theContainer with properties {name:theName}
set end of output to result as alias
move temp to result
display notification "成功新建目录" & theName & "并且移动目录" & POSIX path of ((targetFolder as text) & theName) with title ("文件: " & theName as text)
end tell
end if
end if
end if
end repeat
return output -- or output
end run
变量:
filterTime: 安装包创建时间过滤,单位为分钟;例如:1,代表最近1分钟内的安装包才会进行移动
targetFolder: 安装包移动的目录路径,会在该路劲下创建同名目录
步骤二:创建Hazel规则
这里规则很简单,根据下载的文件名称过滤,如果满足dmg结尾,说明是APP安装包,然后触发Automator 工作流,进行同名文件新建和安装包移动
Automator CICD Consul Consul-template docker docker-compose elasticsearch gitlab gitlab-runner harbor Hazel hybris java kubernetes mac macx高效率 nginx rancher spring boot spring cloud swarm 分布式 序列号 有规则