TommyJay

Q: Automator Script: mount all drives

Hi All, I have downloaded a small automator app, when run it disconnects all my mounted drives. Sometimes it works, sometimes it doesn't. I just wanted it as a time saver, since I regularly have 5 drives (5 partitions made from 4 drives).

 

Screen Shot 2016-01-03 at 10.19.13 PM.png

I wanted to make the opposite, because usually I only eject the drives but don't physically disconnect them. Going to disk utility and mounting all those drives is actually a bigger pain then ejecting them all from desktop/finder. Can anyone help me make this script mount all the connected drives?

MacBook Pro, OS X Mavericks (10.9.2)

Posted on Jan 3, 2016 1:23 PM

Close

Q: Automator Script: mount all drives

  • All replies
  • Helpful answers

  • by Roote,

    Roote Roote Jan 3, 2016 5:09 PM in response to TommyJay
    Level 2 (417 points)
    Jan 3, 2016 5:09 PM in response to TommyJay

    Hi TommyJay. There is a really useful menu bar app by appgineers called Mountain that will let you eject and remount individually or by group. It has configureable preferences including global hotkeys.

    mountain.png

  • by TommyJay,

    TommyJay TommyJay Jan 3, 2016 5:20 PM in response to Roote
    Level 1 (5 points)
    Jan 3, 2016 5:20 PM in response to Roote

    Thanks for the tip, Roote. I wouldn't even mind that it's a paid app, but the main reason I want to do it with automator is because can simply launch the app through Flic or Unified Remote or iCal. I love how automation can do simple things, like unmount drives when I'm leaving, and I'd also like to do something like 'triggering an app' to mount them back when I come back... The Mountain app seems great with it's keyboard shortcuts, but for example I can't make iCal do a key stroke, but it can open an app..

  • by Roote,

    Roote Roote Jan 3, 2016 7:47 PM in response to TommyJay
    Level 2 (417 points)
    Jan 3, 2016 7:47 PM in response to TommyJay

    To use iCal with Mountain, first set your global hotkey in Mountain. For instance, to mount your drives you might use Shift-Option-Command-M.

     

    hotkeys.png

    In Automator create a new Calendar Alarm and add a Run AppleScript action to the workflow. Add the following lines:

     

    tell application "System Events"

    keystroke "m" using {shift down, option down, command down}

    end tell

    Mount002.png

    Save it with a name such as Mount Drives. An Automator calendar and the event will be automatically added to the Calendar app. In Calendar schedule the event to your preference.

    Mount003.png

    As far as Flic and Unified Remote, if you use those programs to launch apps, be aware that you can create an Automator app using the Run AppleScript action and also save an Applescript as an app from Script Editor.

    Mount004.png

    To use either app In Calendar, create a new event, select Custom as the alert, Open file, Other, and select either the Automator app or AppleScript app you created.

    Mount005.png

  • by TommyJay,

    TommyJay TommyJay Jan 9, 2016 1:40 PM in response to Roote
    Level 1 (5 points)
    Jan 9, 2016 1:40 PM in response to Roote

    @Roote, I thank you for the time you took to go through it and explain everything to me. Nevertheless, it seems like a workaround, not a solution. My goal was to use only simple Automator, and you found a way to use a third party app to work with automator.

  • by Roote,

    Roote Roote Jan 10, 2016 4:28 AM in response to TommyJay
    Level 2 (417 points)
    Jan 10, 2016 4:28 AM in response to TommyJay

    You're welcome. No problem, I understand. With the drives connected you want to mount, run the following command in Terminal to list them and locate the Device Identifier for each device (i.e disk1, disk2, etc.):


    diskutil list

     

    You'll see a list of drives similar to this:

    terminal.png

    In the example above disk0 is the internal boot drive, disk1 and disk2 the connected external drives.

     

    Once you have the Device Identifier for each drive (i.e disk1, disk2, disk3, disk4) you can try this simple Automator workflow/application/etc using a Run AppleScript action:

     

    on run {input, parameters}

    set diskutil to "usr/sbin/diskutil"

    do shell script diskutil & " mountDisk disk1 > /dev/null 2>&1 &"

    do shell script diskutil & " mountDisk disk2 > /dev/null 2>&1 &"

    do shell script diskutil & " mountDisk disk3 > /dev/null 2>&1 &"

    do shell script diskutil & " mountDisk disk4 > /dev/null 2>&1 &"

    return input

    end run

    applescript.png

    Alternatively you can use a faster Run Shell Script action in Automator:

     

    diskutil mountDisk disk1 > /dev/null 2>&1 &

    diskutil mountDisk disk2 > /dev/null 2>&1 &

    diskutil mountDisk disk3 > /dev/null 2>&1 &

    diskutil mountDisk disk4 > /dev/null 2>&1 &

    shellscript.png

    Tested with OS X Yosemite 10.10.5 and OS X Mavericks 10.9.5