Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

alec6542

macrumors regular
Original poster
Jan 16, 2012
111
2
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"

Screen Shot 2013-04-29 at 11.12.56 PM.png

Screen Shot 2013-04-29 at 11.12.37 PM.png

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

Intell

macrumors P6
Jan 24, 2010
18,955
509
Inside
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.
 

see.solve.

macrumors newbie
Oct 13, 2012
20
0
Easier, I think, is to use 'quoted form of', ie:
Code:
do shell script "diskutil mount " & quoted form of part
 

jsdraven

macrumors newbie
Aug 14, 2013
5
0
Sonora, CA
Easier, I think, is to use 'quoted form of', ie:
Code:
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.

Code:
set volumeName to "/Volumes/Some Drive/here" as text
do shell script "diskutil mount " & quoted form of volumeName with administrator privileges
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.