Want to highlight a helpful answer? Upvote!

Did someone help you, or did an answer or User Tip resolve your issue? Upvote by selecting the upvote arrow. Your feedback helps others! Learn more about when to upvote >

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

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).


User uploaded file

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

Reply
Question marked as Best reply

Posted on Jan 3, 2016 5:09 PM

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.

User uploaded file

5 replies

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..

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.


User uploaded file

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

User uploaded file

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.

User uploaded file

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.

User uploaded file

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.

User uploaded file

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:

User uploaded file

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

User uploaded file

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 &

User uploaded file

Tested with OS X Yosemite 10.10.5 and OS X Mavericks 10.9.5

Automator Script: mount all drives

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.