How to handle a file that is not there

I’m try to write an applescript to delete my backup of my Favorites.html file. The script i have works great untill i manaully delete the file then run the script.
I get a error " Finder got an error: can’t find file “backups:mac:CGIT_TEST:Favorites.html”. " is their a way i can check to see if the file is there before trying to delete it.


tell application "Finder"
	activate
	select file "backups:mac:CGIT_TEST:Favorites.html"
	delete selection
end tell 

thanks for any help you can give. K :slight_smile:

Does this work?

set path_ to "backups:mac:CGIT_TEST:Favorites.html"

tell application "Finder" to ¬
	if exists file path_ then delete file path_

– Rob

thanks rob that worked great!

K :slight_smile: