Verifying mounted disk

In many of the scripts I am currently programming I often have to ensure required disks are mounted.

In order to be more efficient I’ve created a small subroutine which send a message to the operator and in the meantime ensure a command is not executed before the disk gets mounted.

I only have to write a one line statement i.e my VerifyMountedDisk(“the SDHC card”, “VolumeName”) each time I need it.

I am sharing this with you in case someone else wants to do the same.:slight_smile:

Regards!
Daniel

 
my VerifyMountedDisk("the SDHC card", "VolumeName")

on VerifyMountedDisk(theMediaInfo, theVolumeName)
	set mounteddisks to list disks
	repeat until mounteddisks contains theVolumeName
		set mounteddisks to list disks
		display dialog "Please insert " & theMediaInfo & " in the computer" with icon 1
	end repeat
end VerifyMountedDisk