Automatically Delete A DMG When You Eject It In OS X

When you install a new app in OS X, it usually comes in the form of a DMG file that you have to then mount, eject, and delete. This simple Automator service simplifies the process, ejecting the disk image and deleting its DMG file in one fell swoop.

Here’s how to create this very simple service:

  1. Open up the Automator application and select “Service”.
  2. Change the top two dropdown menus to receive “No Input” from the “Finder”.
  3. In the left sidebar, drag the “Run AppleScript” action into the right pane. Copy the following code into the box:
    tell application "Finder"
    
    set selection_list to selection
    
    if (count selection_list) 
    
  4. Save the service as whatever you want (like “Eject & Delete DMG”) and exit Automator.

Now, when you’re done using a DMG file, you can just click on it, then go to Finder > Services > Eject & Delete DMG to eject the image and delete the DMG with one click. If you really want to make it fast, you can go to System Preferences > Keyboard > Keyboard Shortcuts and give your service a handy keyboard shortcut. Note that this doesn’t work if you select the DMG in the Finder sidebar; you have to select it in an actual Finder window (or on the desktop). Hit the link to read more.

Auto-Delete a DMG File When Ejecting a Disk Image [Mac OS X Hints]


The Cheapest NBN 50 Plans

Here are the cheapest plans available for Australia’s most popular NBN speed tier.

At Lifehacker, we independently select and write about stuff we love and think you'll like too. We have affiliate and advertising partnerships, which means we may collect a share of sales or other compensation from the links on this page. BTW – prices are accurate and items in stock at the time of posting.

Comments


2 responses to “Automatically Delete A DMG When You Eject It In OS X”

Leave a Reply