• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: AppleScript to erase one mounted volume if it's modification date is date is greater than one day?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript to erase one mounted volume if it's modification date is date is greater than one day?


  • Subject: Re: AppleScript to erase one mounted volume if it's modification date is date is greater than one day?
  • From: Kaydell Leavitt <email@hidden>
  • Date: Fri, 21 Jun 2013 03:57:56 -0600

Phil,

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

-- Kaydell

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?



Best

Phil
http://applehelpwriter.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: AppleScript to erase one mounted volume if it's modification date is date is greater than one day?
  • Next by Date: changing background image of Terminal.app
  • Previous by thread: Re: AppleScript to erase one mounted volume if it's modification date is date is greater than one day?
  • Next by thread: changing background image of Terminal.app
  • Index(es):
    • Date
    • Thread