Getting notification when hard drive is mounted

Discussion in 'Mac Basics and Help' started by stephenbakertv, Apr 28, 2016.

  1. stephenbakertv macrumors newbie


    Apr 28, 2016
    I want to know when a hard drive is added to my work Mac, ie get an email or text when one of my workers mount a hard drive to our work computer. Then I can remote log in and go to work. There was an App called Growl but apparently this ability is part of Mac OS.....Any ideas?
  2. 0d085d macrumors regular

    Apr 23, 2015
    This sounds like a job for a Folder Action.

    Open the Automator app and choose "Folder Action" as the type of workflow. At the top of the workflow, select "Other..." where it says "Folder Action receives files and folders added to". In the choose folder dialog box that pops up, press cmd+shift+g and go to /Volumes. Click "Choose".

    Then, add a "Run Applescript" item and copy in the following script (changing your name and email address at the top):

    on run {input, parameters}
        set myName to "Your name here"
        set myEmail to ""
        set theDrive to "none"
        repeat with f in input
            display notification "Drive mounted: " & (POSIX path of f)
            set theDrive to (POSIX path of f)
        end repeat
        -- Uncomment next 3 lines to only send an email for a particular drive
        -- if theDrive is not "/Volumes/Backups" then
        --    return
        -- end if
        tell application "Mail"
            set theMessage to make new outgoing message with properties {subject:"New drive mounted", content:"The following new mount has been detected: " & theDrive, visible:true}
            tell theMessage
                make new to recipient with properties {name:myName, address:myEmail}
            end tell
        end tell
    end run
    Save the workflow and you should be done. It will run automatically whenever a drive is plugged in.

    Attached Files:

Share This Page