目录:
考虑到这一点,这次我们将分享一些简洁的小工作流程,您可以使用Automator在Mac上实现这些工作流程。 使用它们中的任何一个,每次完成Mac上的应用程序安装,您只需点击几下即可弹出/卸载并删除磁盘映像。
让我们开始介绍如何设置这些不错的Automator工作流程。
当你弹出它们时自动删除DMG文件
步骤1:打开Automator并选择创建新文档。 从显示在对话框中的可用文档类型中,选择“ 服务” 。
步骤2:在右侧面板的顶部,确保分别从下拉菜单中选择 “无输入” 和 “查找” 选项,以便最终结果如下图所示。
步骤3:接下来,在Automator的左侧面板上,搜索 Run AppleScript 操作并将其拖动到右侧面板。 AppleScript窗口将显示一些占位符代码。
删除该代码,然后在脚本框中复制并粘贴以下代码:
tell application "Finder"
set selection_list to selection
if (count selection_list) < 1 then
display dialog
"Please select a volume mounted from a disk image." with title
"No Selection Found" with icon stop
buttons default button 1
return
end if
set my_selection to item 1 of selection_list
set my_kind to kind of my_selection
set my_name to name of my_selection
if my_kind is not "Volume" then
display dialog
"Please select a volume mounted from a disk image file." with title
"Selection is not a Disk Image" with icon stop
buttons default button 1
return
end if
set volume_list to paragraphs of (do shell script "hdiutil info | grep ^/dev/disk | grep -o '/Volumes/.*'")
set source_list to paragraphs of (do shell script "hdiutil info | grep ^image'-'alias | grep -o '/.*'")
set match_found to false
repeat with v from 1 to (count volume_list)
if "/Volumes/" & my_name = item v of volume_list then
set match_found to true
exit repeat
end if
end repeat
if match_found is not equal to true then
display dialog
"The selected volume does not appear to be a Disk Image." with title
"Could not find Disk Image" with icon stop
buttons default button 1
return
else
set my_source to POSIX file (item v of source_list) as alias
move my_source to the trash
eject my_selection
--reveal my_source
end if
end tell
第4步:现在保存此Automator服务并为其命名,易于记忆。
现在,让我们来看看另一个Automator工作流程,它实现了完全相反的目标。
将它们拖动到废纸篓时自动弹出DMG文件
正如您从标题中看到的那样,此Automator工作流程允许您实现相同的目的,除了反向,因此您可以在每次拖动已挂载的DMG文件时废弃此消息。
第2步:在右侧面板的顶部,从下拉菜单中选择 其他…. 然后,在弹出的对话框中,键入 〜/.Trash 以使用该文件夹。