Saturday, January 19, 2019

#1 2019-01-04 11:10:51 pm

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 32
Website

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


Public servants are people too

Offline

 

#2 2019-01-05 05:02:06 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5516

Re: Finder slow to recognise file system changes ?

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

Applescript:

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


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#3 2019-01-08 11:58:27 pm

Neophyte
Member
From:: Canberra, ACT, Australia
Registered: 2017-08-20
Posts: 32
Website

Re: Finder slow to recognise file system changes ?

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.


Public servants are people too

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)