• 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: If/Then Statements
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: If/Then Statements


  • Subject: Re: If/Then Statements
  • From: Luther Fuller <email@hidden>
  • Date: Tue, 26 Jan 2010 10:04:07 -0600

On Jan 26, 2010, at 9:11 AM, email@hidden wrote:

I am essentially creating a uninstaller script. The script I have works but if any element is already gone then it hangs at that point and gives an error. I need to put in some kind of if/then statement I believe so that when an error is returned it will move to the next line and so on until finished. Any suggestions out there would be much appreciated.

do shell script "rm -r /Applications/Utilities/'Keychain Minder.app'" with administrator privileges

I do that too. There are two ways to do it.
First ...

tell application "Finder"
if (exists file "fileName" of locationAlias) then
(file "fileName" of locationAlias) as alias
tell application "System Events" to delete disk item (the result as text)
end if
end tell

Or you can use this ...

tell application "Finder"
try
((locationAlias as text) & "fileName") as alias
tell application "System Events" to delete disk item (the result as text)
end try
end tell

If the file does not exist, then creating the alias from a text path fails.
Using "System Events" avoids putting anything in the Trash.

 _______________________________________________
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

References: 
 >If/Then Statements (From: email@hidden)

  • Prev by Date: Applescript book recommendation
  • Next by Date: Re: Determining Binary Type
  • Previous by thread: Re: If/Then Statements
  • Next by thread: Determining Binary Type
  • Index(es):
    • Date
    • Thread