Finder slow to recognise file system changes ?

My AppleScript applet has installer code which creates a preferences folder and file if they don’t exist. It uses Finder to check existence. The applet also has uninstaller code which uses “mv” via calls to “do shell script” to move the preferences file and folder to Trash.

Problem: if I run the uninstall then run the install shortly after, the install code reports that the preferences file exists, when it clearly does not. If I run the install a number of times it still reports that the file and folder exist. If in Finder I then open the ~/Library/Preferences folder and immediately run the install again, it reports correctly that the file does not exist.

I’ve noticed before that if files are moved using the Shell, Finder seems to take some time to update. I’ve also seen files disappear from windows as Finder catches up.

It there a more reliable way than Finder to test whether a file exists ? For example, System Events, a shell script or AppleScript code ?

Thanks.

Garry

You can try creating an alias, which fails if the file doesn’t exist:

try
  "Macintosh HD:folder:file" as alias
  set fileExists to true
on error
  set fileExists to false
end try

Shane, many thanks that’s a good idea. For the time being, I’m using System Events instead of Finder. There have been no glitches so far.

Cheers.