Simplicity confused... CONTAINS CODE

I wrote a very short, simple script to delete a particular file without making me dig for it:

tell application "Finder"
	if exists "HDX:Applications:FileMaker Pro 8.5 Advanced:FileMaker Java Extensions:JavaCompanion Log" then
		select item "HDX:Applications:FileMaker Pro 8.5 Advanced:FileMaker Java Extensions:JavaCompanion Log"
		delete selection
	end if
end tell

The first time I run it on a given day, it deletes not only the file but the folder containing it.

I manually take the folder out of the Trash, put it back where it belongs.

Run the script a second time, it deletes just the file.

Any idea why I can’t trust this to delete only what it is supposed to delete?


Model: eMac
Browser: Firefox 2.0
Operating System: Mac OS X (10.4)


I have no idea why, but it may be due to some unecessary steps you have. You do not need to select a file in order to delete it:

set delete_this to "Pilate:Users:cas:Library:Mail Downloads:meeting.ics"
tell application "Finder"
	if exists file delete_this then delete file delete_this
end tell

I used to do things in OS9 and earlier mainly by recording my actions and copy/pasting/modifying as necessary.

This thing doesn’t record, so a lot of stuff was being dredged up out of memory.

This works.