Script that will mount an external HD

Discussion in 'Mac Programming' started by Dr Kevorkian94, Dec 8, 2011.

  1. macrumors 68020

    Joined:
    Jun 9, 2009
    Location:
    SI, NY
    #1
  2. Partron22, Dec 8, 2011
    Last edited: Dec 8, 2011

    macrumors 65816

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #2
    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
     
  3. thread starter macrumors 68020

    Joined:
    Jun 9, 2009
    Location:
    SI, NY
    #3
    I sort of understand that but i can't figure out how to get it to work in the applescript editor.
     
  4. macrumors 65816

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #4
    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.
     
  5. Dr Kevorkian94, Dec 8, 2011
    Last edited: Dec 8, 2011

    thread starter macrumors 68020

    Joined:
    Jun 9, 2009
    Location:
    SI, NY
    #5
    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.
     
  6. Partron22, Dec 8, 2011
    Last edited: Dec 8, 2011

    macrumors 65816

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #6
    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
     
  7. thread starter macrumors 68020

    Joined:
    Jun 9, 2009
    Location:
    SI, NY
    #7
    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.
     
  8. macrumors 65816

    Partron22

    Joined:
    Apr 13, 2011
    Location:
    Yes
    #8
    The 'Connect to server' item in the Finder's 'Go' menu should also give you that information.
     
  9. Dr Kevorkian94, Dec 8, 2011
    Last edited: Dec 8, 2011

    thread starter macrumors 68020

    Joined:
    Jun 9, 2009
    Location:
    SI, NY
    #9
    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.
     

Share This Page