I am trying to write an applescript that will allow me to delete multiple files on a computer, and then do a secure empty trash.
My problem is that lets say one of the specified files is not on the computer, how do I have the Applescript still proceed with the rest of the applescript.
This applescript is needed for deletion of old programs on school computers. Some computers have all of the programs and others do not.
Currently all that happens if this will delete files until applescript gets to a program not on the system, and then if stops the program to tell me of the non existent application.
Instead I would like the applescript to:
-
delete all of the specified files it can find on the computer
-
secure empty the trash
-
prompt me with an error dialog box that details what applications were not found on the system
Any help would be greatly appreciated.
Regards,
paulmattallen
do shell script "command" user name "Your Computer" password "passcode" with administrator privileges
try
set theFile to "/Users/bradleyelementary/Desktop/santas 2.qtz"
do shell script "rm -R " & quoted form of theFile & "" with administrator privileges
do shell script "/usr/bin/srm -mz $HOME/.Trash/*" with administrator privileges
on error
display dialog "The following applications were not found on this system..." with icon caution with title "Error" giving up after 5
end try