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