我找到了这篇文章... http://www.guidingtech.com/26874/eject-delete-dmg-files-automatically/我的问题与页面的第二部分有关。
它似乎不再适用于 El Cap。尝试了终端中的各个行,发现“弹出”需要更改为“分离”。我还将 ### 更改为 === 以匹配 detach 命令的输出,但它似乎不起作用。我知道文件夹操作正在触发,因为我在 automator 中选中了“在工作流运行时显示此操作”,并且它确实弹出。
这是我所拥有的:
import string, os, sys
lines = os.popen("hdiutil info").readlines()
should_eject = False
for line in lines:
if line.startswith("image-alias"):
path = line.split(":")[1]
image_path = path.lstrip().rstrip()
if image_path in sys.argv:
should_eject = True
elif line.startswith("/dev/") and should_eject is True:
os.popen("hdiutil detach -force " % line.split()[0])
should_eject = False
elif line.startswith("==="):
should_eject = False