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

LoChrome

macrumors newbie
Original poster
May 5, 2012
2
0
I keep my music stored on an AirPort volume (I have an Air and too much music for the HD). I'm trying to write an AppleScript to check if my volume is mounted—and if not, mount it—before launching iTunes. Because the volume is a partition on the hard drive, I can't figure out how to reference it directly.

This works okay, but it's crude: it requires I pick the Music partition/volume from a list before mounting it, and if it's already mounted, mount a disk I don't want to mount.

Code:
mount volume "afp://MyVolume._afpovertcp._tcp.local"
launch application "iTunes"

(The full Music drive address is "afp://MyVolume._afpovertcp._tcp.local/Music Storage")

The ideal solution would check to see if I'm connected to my Wi-Fi network, mount the disk, then mount iTunes, but I'm really at a loss to do that. Any help to make this work better would be appreciated. I could do this as an AppleScript, Terminal script or Automator app.

Thanks! :apple:
 
Code:
tell application "Finder"
	if (exists disk "Music Storage") then
		launch application "iTunes"
	else
		try
			mount volume "afp://MyVolume._afpovertcp._tcp.local/Music Storage"
			repeat until disk "Music Storage" exists
			end repeat
		on error theErrorText number theErrorNumber
			display dialog "An error occured. The following error number " & theErrorNumber & " was encountered: " & theErrorText buttons {"OK"} default button 1
		end try
		launch application "iTunes"
	end if
end tell


To return a list of the currently mounted volumes :

Code:
tell application "System Events" to get the name of every disk
-- → list of text : a list of the currently mounted volumes.
 
Last edited:
Oddly, when using my original AppleScript app, my volume properly mounts. When I tried yours, which has the identical mount volume language, I get a "Finder got an error: Network file permission error."

When I was first playing with AppleScript Editor trying to get something to work, I kept getting this same problem. I'm completely baffled as to why the same bit of code executes differently in the different contexts.

Thanks for the more graceful code. I would be an improvement on my solution if it weren't for the baffling permissions bug. (My regular user environment isn't my admin profile, so that may be related to the problem.)
 
I also have my media on an airport drive. About half the time, the computer will automatically mount the drive if I try to access it through iTunes. Sometimes it does not. I don't know why.
 
What userame and password are you using? How did you configure your AirPort in relation to sharing a drive? The first time you connected did you save anything in Keychain Access? Try this :

Code:
mount volume "afp://user:pass@MyVolume._afpovertcp._tcp.local/Music Storage"
or
mount volume "afp://MyVolume._afpovertcp._tcp.local/Music Storage" as user name "user" with password "pass"
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.