You are right. I had some problems with the space in the volume name and I changed the spec but forgot to put that in my answer.
Here is an answer that satisfies part of the OP's question (the part about erasing the drive but not about determining when to erase it)
-- This script is an example of how to erase an entire volume quickly in AppleScript by calling the shell command "diskutil"
-- set a variable to name the volume to be erased
set temporaryDrive to "Temporary Drive"
-- add extra quotes to the drive name in case it has any spaces in it
set temporaryDrive to "'" & temporaryDrive & "'"
-- display a warning to the user, warning him or her that if they continue the drive will be erased
display dialog "Warning!!! This script will erase the volume called " & temporaryDrive & " are you sure that you want to do this?"
-- erase the drive, requiring an adminstrator's password
set theCommand to "/usr/sbin/diskutil eraseVolume HFS+ " & temporaryDrive & " /Volumes/" & temporaryDrive
do shell script theCommand with administrator privileges
From what I can tell, the OP’s drive is called “Temporary Drive” not “TemporaryDrive” so that first line’s going to need to be
set temporaryDrive to “Temporary Drive”
I haven’t quite figured out how get the modification date of the drive yet, though.
AFAIK, you can only get the last accessed date of files on the drive, not the drive itself, so the question is:
- which file, if any, would give you a foolproof answer every time?