Does that the job?
set mountedDiskName to "AirPort Time Capsule"
set diskIsMounted to false
tell application "System Events" to set diskNames to name of every disk
if mountedDiskName is in diskNames then
set diskIsMounted to true
end if
if diskIsMounted then
log "Disk Found, unmounting now..."
do shell script "diskutil unmountDisk" & space & quoted form of mountedDiskName
else
log "Disk Not Found, mounting now…"
mount volume "afp://AirPort%20Time%20Capsule._afpovertcp._tcp.local"
end if
Update
I thought you want to unmount the disk when mounted but that was wrong :) here a shorter version:
tell application "System Events" to set diskNames to name of every disk
if "AirPort Time Capsule" is in diskNames then
display dialog "Disk already mounted" buttons {"OK"} default button 1 with icon 1
else
mount volume "afp://AirPort%20Time%20Capsule._afpovertcp._tcp.local"
end if
…or, if you want the disk name in the dialog:
set diskName to "AirPort Time Capsule"
tell application "System Events" to set diskNames to name of every disk
if diskName is in diskNames then
display dialog quoted form of diskName & " is already mounted." & return buttons {"OK"} default button 1
else
mount volume "afp://AirPort%20Time%20Capsule._afpovertcp._tcp.local"
end if