View Full Version : Mounting a partition with AppleScript that has a space in the name

Apr 29, 2013, 11:20 PM
Hi guys,

I am trying to get this AppleScript I found online to work which is a quick way to mount unmounted volumes. For some reason, the script works just fine for any volume that is does not have a space in the name. For any that does (such as Macintosh HD in my case), I get an error message, which is in the screenshot below. I know the problem has to do with the space, because if I open terminal and run "diskutil mount Macintosh\ HD" (which the forward slash for space), the volume mounts just fine. But, if I try to put a forward slash in the Applescript, I get another error message. Here is both the script and the error message. In my case, "Media"



Any help is appreciated. I did google this with several different search criteria and did not find a clear answer.

May 2, 2013, 03:12 PM
Anyone? I thought for sure this was a trivial issue.

May 2, 2013, 03:14 PM
It has to have two slashes, like this: "diskutil mount Macintosh\\ HD" The first is an escape for Applescript and the second is an escape for bash.

May 4, 2013, 08:20 AM
Easier, I think, is to use 'quoted form of', ie:
do shell script "diskutil mount " & quoted form of part

Aug 14, 2013, 04:04 PM
Easier, I think, is to use 'quoted form of', ie:
do shell script "diskutil mount " & quoted form of part

That is the best then you could be a little more free with your name spaces. ie if you would like your output to be...

$sudo diskutil mount "/Volume/Some Drive/here"

Then I would do the following.

set volumeName to "/Volumes/Some Drive/here" as text
do shell script "diskutil mount " & quoted form of volumeName with administrator privileges