0

I found this article...http://www.guidingtech.com/26874/eject-delete-dmg-files-automatically/ My question relates to the second part of the page.

It doesn't seem to work anymore in El Cap. Tried individual lines in terminal, and found "eject" needed to be changed to "detach". I also changed ### to === to match output from the detach command however it doesn't seem to work. I know folder action is firing because I checking "Show this action when workflow runs" in automator, and it does popup.

Here's what I have:

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
cycle4passion
  • 3,081
  • 3
  • 14
  • 28

1 Answers1

0
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 eject %s" % line.split()[0])
        should_eject = False
    elif line.startswith("==="):
        should_eject = False
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
cycle4passion
  • 3,081
  • 3
  • 14
  • 28