Skip to content

AppleScript To Help With iTunes Media on Network Drives.

January 28, 2012

I created this AppleScript because I wanted to store my iTunes Media from a shared Windows box but run iTunes on my Mac becuase iTunes is so GD awful on Windows. What this script does is the following:

  1. Ping the IP address of the Windows Box (172.168.10.5)
    1. If the computer is Un-reachable you get a pop-up asking to Retry or Cancel. 
    2. If the computer is online the process continues. 
  2. Mount the shared volume. (I have 2; Storage and Storage2)
  3. Check that the shared folder(s) acutally mounted to the Finder.
    1. If one or both disks do not mount than an error tells you which one is not there and gives you the option to Cancel or Retry.
    2. If all disks are mounted to the Finder, iTunes is launched. 

You are welcome to download this AppleScript from the link below and change as you need or copy and paste below code into AppleScript, make changes and save as Application. 

You will need to change the following information:

  • IP address of the computer you share files from. (Mine is 172.16.10.5)
  • Name of the computer you store media on.  (Mine is WHS)
  • Change network drive from SMB to AFP or NFS if needed.
  • Change the name of the shared folder(s).  (Mine are Storage and Storage2)

Downlaod from HERE.

 

set x to 0
set t to 0
set s to 0
repeat until t = 1
try
set t to 1
do shell script "ping -c1 172.16.10.5"
on error number 2
set decision to display dialog ("Unable to start iTunes because the server 'WHS' can not be found. Please check that the server is turned on and connected to the network then press 'Retry'.") buttons {"Retry", "Cancel"} default button 1 with icon note
if button returned of decision is "Retry" then
set t to 0
end if
end try
end repeat
repeat until x = 1
try
mount volume "smb://172.16.10.5/Storage"
mount volume "smb://172.16.10.5/Storage2"
end try
#delay 5
tell application "Finder"
if exists disk "Storage" then
set s to s + 1
end if
if exists disk "Storage2" then
set s to s + 2
end if
if s = 3 then
tell (launch application "iTunes")
tell application "iTunes"
activate
end tell
end tell
set x to 1
else if s = 2 then
set decision to display dialog ("Unable to start iTunes, cannot connect to drive 'Storage'.") buttons {"Retry", "Cancel"} default button 1 with icon note
if button returned of decision is "Retry" then
set s to 0
end if
else if s = 1 then
set decision to display dialog ("Unable to start iTunes, cannot connect to drive 'Storage2'.") buttons {"Retry", "Cancel"} default button 1 with icon note
if button returned of decision is "Retry" then
set s to 0
end if
else if s = 0 then
set decision to display dialog ("Unable to start iTunes, cannot connect to network drives.") buttons {"Retry", "Cancel"} default button 1 with icon note
if button returned of decision is "Retry" then
end if
end if
end tell
end repeat

 

Advertisements

From → Tutorial

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: