Mac Script that will mount an external HD

Partron22

macrumors 68030
Apr 13, 2011
2,565
756
Yes
This Applescript should do it for you:
Code:
set volumename to "Betelgeuse" -- change this to the volume name you want

try
	do shell script "diskutil mount " & quoted form of volumename
	
	-- To unmount the volume use:
	-- do shell script "diskutil unmount /Volumes/" & quoted form of volumename
	
	-- To start up iTunes use
	-- tell application "iTunes" to activate
	
on error
	-- something went wrong with the mount, or unmount
	-- you can try to fix it here
end try
see http://hints.macworld.com/article.php?story=20041024142036862
 
Last edited:

Dr Kevorkian94

macrumors 68020
Original poster
Jun 9, 2009
2,137
31
SI, NY
This Applescript should do it for you:
Code:
set volumename to "Betelgeuse" -- change this to the volume name you want

try
	do shell script "diskutil mount " & quoted form of volumename
	
	-- To unmount the volume use:
	-- do shell script "diskutil unmount /Volumes/" & quoted form of volumename
	
	-- To start up iTunes use
	-- tell application "iTunes" to activate
	
on error
	-- something went wrong with the mount, or unmount
	-- you can try to fix it here
end try
see http://hints.macworld.com/article.php?story=20041024142036862
I sort of understand that but i can't figure out how to get it to work in the applescript editor.
 

Partron22

macrumors 68030
Apr 13, 2011
2,565
756
Yes
Copy the text in that "Code" block into an AppleScript Editor window
Change the word "Betelgeuse" to whatever the name of your drive is.
Click the run button.
It should mount the drive.

All those lines that start with --
are comments.

If you remove the -- from the "-- tell application "iTunes" to activate"
The script will start up iTunes after mounting the drive.
 

Dr Kevorkian94

macrumors 68020
Original poster
Jun 9, 2009
2,137
31
SI, NY
Copy the text in that "Code" block into an AppleScript Editor window
Change the word "Betelgeuse" to whatever the name of your drive is.
Click the run button.
It should mount the drive.

All those lines that start with --
are comments.

If you remove the -- from the "-- tell application "iTunes" to activate"
The script will start up iTunes after mounting the drive.
This is what i had done, and it give me error: "Unable to find disk for Kevorkian" number 1. The eternal HD is in the finder under the shared section, that might have something to do with it.
 
Last edited:

Partron22

macrumors 68030
Apr 13, 2011
2,565
756
Yes
The eternal HD is in the finder under the shared section
Oh, it's a network device!
That's different: You want something like this:
Code:
set mypth to "afp://XXX._afpovertcp._tcp.local/YYY" -- Get this from the Finder's get Info window for the network disk after you mount it manually The information you want is the "Server:" line.
set err to false
tell application "Finder"
	try
		mount volume mypth
	on error
		set err to true
	end try
end tell
if err is equal to false then
	tell application "iTunes"
		activate
	end tell
end if
-- MountNetworkDrives
-- see: http://www.theothertomelliott.com/node/232
-- Or, you can just put these paths as url's in the startup items folder
-- see also: http://hints.macworld.com/article.php?story=20050215082247458
 
Last edited:

Dr Kevorkian94

macrumors 68020
Original poster
Jun 9, 2009
2,137
31
SI, NY
Oh, it's a network device!
That's different: You want something like this:
Code:
set mypth to "afp://XXX._afpovertcp._tcp.local/YYY" -- Get this from the Finder's get Info window for the network disk after you mount it manually The information you want is the "Server:" line.
set err to false
tell application "Finder"
	try
		mount volume mypth
	on error
		set err to true
	end try
end tell
if err is equal to false then
	tell application "iTunes"
		activate
	end tell
end if
-- MountNetworkDrives
-- see: http://www.theothertomelliott.com/node/232
-- Or, you can just put these paths as url's in the startup items folder
-- see also: http://hints.macworld.com/article.php?story=20050215082247458
Good, the only problem is that apparently in get info its not showing any info but ill fiddle with it. next i was hoping to run the script in geek tool and have it so when i was to open iTunes the script would know and then it would connect to the HD so my music would be there.
 

Partron22

macrumors 68030
Apr 13, 2011
2,565
756
Yes
The 'Connect to server' item in the Finder's 'Go' menu should also give you that information.
 

Dr Kevorkian94

macrumors 68020
Original poster
Jun 9, 2009
2,137
31
SI, NY
ok so i just have to set it up correctly so when i open iTunes it will connect to the HD so my music is there

Edit: I don't think this is going to work the way i want so I'm going to start a new thread to see if i can just stay connected.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.