This is what I came up with...
--Eject Bootable Clone
--
-- Ejects a list of particularly-named disks whenever one mounts
--
-- Folder Action: to be
-- Stored in /Library/Scripts/Folder Action Scripts
-- Attached to the folder named /Volumes
--
property EjectableDiskNames : {"Orange Clone"}
on adding folder items to theVolumesFolder after receiving theseItems
tell application "Finder"
repeat with aDisktoEject in EjectableDiskNames
if exists (disk aDisktoEject) then
display dialog "Disk \"" & aDisktoEject & "\" mounted." & return & ¬
"If you do nothing, it will be ejected in a few seconds." buttons {"Keep it mounted.", "Eject it now."} ¬
default button ¬
"Eject it now." giving up after 5
set theResult to the result
if (gave up of theResult) ¬
or (button returned of theResult is "Eject it now.") then
display dialog "Ejecting disk \"" & aDisktoEject & ¬
"\" now." giving up after 2
eject (every disk whose name is aDisktoEject) -- Thanks, Phil
else
display dialog "Leaving disk \"" & aDisktoEject & ¬
"\" mounted." giving up after 2
end if
end if
end repeat
end tell
end adding folder items to
...and its companion...
--Mount Bootable Clone
--
-- Mounts a list of disks (by disk name)
-- that are plugged in, but not mounted
-- because they have been ejected
property zero : 0
property one : 1
property nullstring : ""
property EjectableDiskNames : {"Orange Clone"}
repeat with diskName in EjectableDiskNames
tell application "Finder"
if disk diskName exists then
display dialog "Disk \"" & diskName & "\" is already mounted."
else
do shell script "diskutil mountDisk " & my devName(diskName)
end if
end tell
end repeat
on devName(diskName)
--Converts a Disk Name to a (Unix) Device Name
-- even if the disk is (plugged in but) not mounted
-- for use with "diskutil mountDisk " & devName(DiskName)
set diskutilReport to do shell script "diskutil list"
(* e.g.:
diskutilReport=/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *320.1 GB disk0
1: EFI 209.7 MB disk0s1
2: Apple_HFS MBProHD 319.7 GB disk0s2
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *320.1 GB disk1
1: EFI 209.7 MB disk1s1
2: Apple_HFS bu MBProHD 320GB 319.7 GB disk1s2
/dev/disk2
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *1.0 TB disk2
1: EFI 209.7 MB disk2s1
2: Apple_HFS Orange Clone 999.9 GB disk2s2
/dev/disk3
...etc.
*)
set DiskNNameBeginsAtch to offset of diskName in diskutilReport -- "Atch" = At character (number)
if DiskNNameBeginsAtch is zero then
error diskName & " not found in diskutil list."
else
set DeviceNNameMightBeginAtch to DiskNNameBeginsAtch - one
repeat while DeviceNNameMightBeginAtch is greater than zero
set testDevN to ¬
(characters DeviceNNameMightBeginAtch through (DeviceNNameMightBeginAtch + 8) of diskutilReport) as string
if testDevN = "/dev/disk" then
return testDevN & character (DeviceNNameMightBeginAtch + 9) of diskutilReport
end if
set DeviceNNameMightBeginAtch to DeviceNNameMightBeginAtch - one
end repeat
end if
error "/dev/diskn not found in diskutil list."
end devName
Thanks again, guys.