I found a script that checks to see if network disks are mounted, and if not mounts them. I managed to get it to work with some disks of my own (a NAS disk connected to my AirPort Extreme, and some disks connected to a different Mac). Here’s an example of the script for one of the disks;
tell application "Finder"
if not (disk "AirDisk 500GB" exists) then
mount volume "afp://airport-extreme.local/AirDisk 500GB" as user name "myname" with password "mypassword"
end if
end tell
But every time the script runs it and the disks are already mounted it unmounts the disks then mounts them again.
Is there any way to stop it from unmounting then mounting again when the script runs and a disk is already connected?
thy this, it checks the folder /Volumes instead of the Finder disk objects
property myDisk : "AirDisk 500GB"
set mountedDisks to paragraphs of (do shell script "/bin/ls /Volumes")
if myDisk is not in mountedDisks then
mount volume "afp://airport-extreme.local/" & myDisk as user name "myname" with password "mypassword"
end if
assuming each disk uses the same user name and password
property myDisks : {"AirDisk 500GB", "AirDisk 320"}
set mountedDisks to paragraphs of (do shell script "/bin/ls /Volumes")
repeat with aDisk in myDisks
if aDisk is not in mountedDisks then
mount volume "afp://airport-extreme.local/" & aDisk as user name "myname" with password "mypassword"
end if
end repeat