PDA

View Full Version : Script that will mount an external HD




Dr Kevorkian94
Dec 8, 2011, 11:14 AM
Ok so I'm moving all of my iTunes library to an external HD (DETAILS: http://forums.macrumors.com/showthread.php?p=13979973#post139799730 and i want a script that will connect to my external hd when i open iTunes so the music is there. so can someone help me with this?



Partron22
Dec 8, 2011, 11:28 AM
This Applescript should do it for you: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

Dr Kevorkian94
Dec 8, 2011, 11:57 AM
This Applescript should do it for you: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
Dec 8, 2011, 12:37 PM
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
Dec 8, 2011, 12:53 PM
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.

Partron22
Dec 8, 2011, 02:14 PM
The eternal HD is in the finder under the shared sectionOh, it's a network device!
That's different: You want something like this:
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

Dr Kevorkian94
Dec 8, 2011, 03:00 PM
Oh, it's a network device!
That's different: You want something like this:
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
Dec 8, 2011, 03:33 PM
The 'Connect to server' item in the Finder's 'Go' menu should also give you that information.

Dr Kevorkian94
Dec 8, 2011, 05:42 PM
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.